制作NSButton调整其图像(Cocoa OSX)(Making an NSButton resize its image (Cocoa OSX))

编程入门 行业动态 更新时间:2024-10-26 20:29:28
制作NSButton调整其图像(Cocoa OSX)(Making an NSButton resize its image (Cocoa OSX))

我无法在文档中找到告诉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.

更多推荐

本文发布于:2023-08-07 02:25:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1458782.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   Cocoa   NSButton   OSX   image

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!