-1

可能重复:
在 NSButton 上使用 -setImage

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!"];

那么如何为这个按钮设置图像呢?

4

2 回答 2

2
[button setBackgroundImage:[UIImage imageNamed:@"yourImage"] forState:UIControlStateNormal];
于 2013-01-21T08:35:49.350 回答
2

你应该使用:

- (void)setImage:(NSImage *)anImage

例如:

[button setImage:[NSImage imageNamed:@"image"]];
于 2013-01-21T08:45:15.183 回答