-1

Possible Duplicate:
Using -setImage on NSButton

I created a button using following code .


    NSView *superview = [_window contentView];
    NSRect frame = NSMakeRect(10, 10, 200, 100);
    button = [[NSButton alloc] initWithFrame:frame];
    [button setTitle:@"Click me!"];

so how can I set a image to this button ?

Community
  • 1
  • 1

2 Answers2

3

You should use:

- (void)setImage:(NSImage *)anImage

e.g.:

[button setImage:[NSImage imageNamed:@"image"]];
Attila H
  • 3,616
  • 2
  • 24
  • 37
2
[button setBackgroundImage:[UIImage imageNamed:@"yourImage"] forState:UIControlStateNormal];
GoGauchos
  • 588
  • 5
  • 11