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!"];
那么如何将图像设置为此按钮?
答案 0 :(得分:2)
[button setBackgroundImage:[UIImage imageNamed:@"yourImage"] forState:UIControlStateNormal];
答案 1 :(得分:2)
您应该使用:
- (void)setImage:(NSImage *)anImage
e.g:
[button setImage:[NSImage imageNamed:@"image"]];