如何设置NSButton背景图片?如何设置NSButton背景图片
[_myButton setImage:[NSImage imageNamed:@"foo.png"]];
这只会改变图像图标按钮,但没什么选项了setBackgroundImage为UIButton
。
如何设置NSButton背景图片?如何设置NSButton背景图片
[_myButton setImage:[NSImage imageNamed:@"foo.png"]];
这只会改变图像图标按钮,但没什么选项了setBackgroundImage为UIButton
。
好吧,这是我所追求的:http://osdir.com/ml/cocoa-dev/2010-06/msg00539.html
设置图像(按名称)。将'位置'仅设置为图标,不设置文字 (从位置按钮阵列左边开始的第二个选项),并取消选中 '加边'。
尝试这样的: - [设置的背景图像的UIButton]的
NSString* img = [[NSBundle mainBundle] pathForResource:@"Your Image" ofType:@"png"];
NSURL* url = [NSURL fileURLWithPath:img ];
NSImage *image = [[NSImage alloc] initWithContentsOfURL: url];
[yourButton setImage: image] ;
[_myButton setImage:[NSImage imageNamed:@"foo.png"]];
[_myButton setBordered:NO];
[_myButton sizeToFit];
可能重复(http://stackoverflow.com/questions/4608454/setting-a-background- image-for-uibutton) – emreoktem
@emreoktem - NSButton不是UIButton – Abizern