zou*_*oul 6 macos cocoa nsbutton
我想要NSButton一张图片和一张替代图片.按下按钮时应显示备用图像,我还想从代码中显示备用图像,调用类似的内容[button setSelected:YES].这可能不用手工编织alternateImage物业吗?
auc*_*uco 16
无需手动更改按钮的图像即可实现:
在Interface Builder(xib/nib编辑器)中,将NSButton 的类型设置为"Toggle",图像将自动更改为备用图像/标题.

您可以使用NSButton类型设置为的NSToggleButton,然后使用的/ 状态在image和之间切换。alternateImageNSOnStateNSOffStateNSButton
NSButton* theButton = [[NSButton alloc] initWithFrame:....];
theButton.image = .....
theButton.alternateImage = .....
theButton.state = NSOffState; // displays the image
theButton.state = NSOnState; // displays the alternateImage
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5735 次 |
| 最近记录: |