丢失了NSButton类型和备用图像 [英] Lost in NSButton types and alternate images
问题描述
我想有一个NSButton
,其中包含一张图片和一张备用图片.按下按钮时,应该显示替代图片,我也想通过代码显示替代图片,并调用类似[button setSelected:YES]
的名称.无需用手操作alternateImage
属性,是否可以做到这一点?
I’d like to have an NSButton
with an image and an alternate image. The alternate image should be displayed while the button is being pressed and I’d also like to display the alternate image from code, calling something like [button setSelected:YES]
. Is this possible without monkeing with the alternateImage
property by hand?
推荐答案
无需手动更改按钮图像即可实现:
This is possible without manually changing the button's image:
在Interface Builder(xib/nib编辑器)中将NSButton的 Type 设置为"Toggle" ,图像将自动更改为备用图片/标题.
In Interface Builder (xib/nib Editor) set the Type of NSButton to "Toggle" and the image will automatically change to the alternate image/title.
这篇关于丢失了NSButton类型和备用图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!