与 NSButton 图像混淆

发布于 2024-12-22 17:38:51 字数 131 浏览 3 评论 0原文

我有一个方形 NSButton 和一个与按钮大小相同的图像。我将图像设置为按钮,关闭边框并将缩放设置为无。然后图像看起来比按钮小。如果我将缩放设置为独立于轴,则图像可以填充所有按钮。但将按钮启用设置为 false。按钮消失了。有谁知道这是怎么回事?

I have a square NSButton and an Image the same size of the button. I set the image to the button, turned off bordered and set scaling to none. Then the image seems smaller than the button. If I set scaling to axes independent, the image can fill the all button. But is set button enable to false. The button disappeared. Does anyone know what's wrong with it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

山田美奈子 2024-12-29 17:38:51

嗯...你的描述,恕我直言,有点混乱!无论如何,据我了解,您的 Xcode 存在问题。

您必须设置缩放比例,因为由于边框的原因,按钮总是比其内容大一点(即使您关闭其边框,它仍然会呈现一个小的不可见边框)。由于未知原因,设置为 Axes Independently 可以解决此问题并以正确的方式调整图像大小(这适用于您可以使用的任何类型的 NSControl)。

我无法弄清楚启用或禁用该按钮如何影响其可见性。您确定您没有使用“隐藏”属性而不是“启用”属性吗?

[myButton setHidden:YES]

这将使按钮透明并且对点击不敏感。

[myButton setEnabled:NO]

这将根据用户点击的答案起作用(这就是您正在寻找的)。你的图像主要是灰色的吗?禁用该按钮将使按钮变灰,这可能会使图像不可见......

Well... Your description, IMHO, is a bit confused! Anyway, for what I understood, you're having problem with Xcode.

You have to set the scaling because the button is always a bit larger than its content, because of the border (even if you turn off its borders, it will still be rendered with a small invisible border). For an unknown reasons, setting to Axes Independently solves this problem and resizes the image in the correct way (this works in any kind of NSControl you can use).

I cannot figure out how enabling or disabling the button can influences its visibility. Are you sure you're not using the "Hidden" property instead of the "Enabled" one?

[myButton setHidden:YES]

This will make the button transparent and insensible to clicks.

[myButton setEnabled:NO]

This will act on the answer to user clicks (and it's what you're looking for). Is your image mainly grey? Disabling the button will make the button gray, and this could make the image invisible...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文