我无法在文档中找到告诉NSButton调整其图像以填充整个按钮的方法。 有没有办法做到这一点编程?
I could not find a way in the documentation to tell an NSButton to resize its image to fill up the whole button. Is there a way to do this programatically?
最满意答案
您将得到的最接近的是-setImageScaling: ...查看常量,以查看图像在按钮单元格内的缩放比例,因为它的边界状态和边框类型。
如果你想用你的图像完全替换标准按钮(即,按钮单元根本不会自己绘制 - 图像用作整个视觉表示),请关闭边框(-setBordered :)。
所有这些选项都可以在IB中配置。 提示:在IB中,将鼠标悬停在检查器面板中的任何设置 - 大多数(如果不是全部的话)都会提示您显示哪种方法控制受设置控制影响的行为。
The closest you'll get is -setImageScaling: ... look up the constants to see how the image will be scaled within the button cell, given its bordered state and bezel type.
If you're looking to replace the standard button entirely with your image (ie, the button cell doesn't draw itself at all - your image serves as the entire visual representation), turn off the border (-setBordered:).
All of these options can be configured in IB as well. A tip: in IB, hover the mouse over any setting in the inspector panel - most if not all give you a hint that shows what method controls the behavior affected by the setting's control.
更多推荐
发布评论