如何设置NSButton背景图像



如何将背景图像设置为NSButton?

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

这只会更改按钮中的图像图标,但没有选项可以将背景图像设置为 UIButton

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

尝试如下:-

NSString* img = [[NSBundle mainBundle] pathForResource:@"Your Image" ofType:@"png"];
NSURL* url = [NSURL fileURLWithPath:img ];
NSImage *image = [[NSImage alloc] initWithContentsOfURL: url];
[yourButton setImage: image] ;
好的,

这就是我所追求的:http://osdir.com/ml/cocoa-dev/2010-06/msg00539.html

设置映像(按名称)。将"位置"设置为仅图标,无文本 (位置按钮数组中左起的第二个选项),然后取消选中 "有边界"。

最新更新