2013-10-22 67 views
0

如何设置NSButton背景图片?如何设置NSButton背景图片

[_myButton setImage:[NSImage imageNamed:@"foo.png"]];

这只会改变图像图标按钮,但没什么选项了setBackgroundImage为UIButton

+0

可能重复(http://stackoverflow.com/questions/4608454/setting-a-background- image-for-uibutton) – emreoktem

+5

@emreoktem - NSButton不是UIButton – Abizern

回答

1

尝试这样的: - [设置的背景图像的UIButton]的

NSString* img = [[NSBundle mainBundle] pathForResource:@"Your Image" ofType:@"png"]; 
NSURL* url = [NSURL fileURLWithPath:img ]; 
NSImage *image = [[NSImage alloc] initWithContentsOfURL: url]; 
[yourButton setImage: image] ; 
4
[_myButton setImage:[NSImage imageNamed:@"foo.png"]]; 
[_myButton setBordered:NO]; 
[_myButton sizeToFit];