iPhoto 类似 NSButton
如何创建像图片中那样的 iPhoto 按钮
我已经尝试了使用圆形纹理的几种方法按钮或将按钮的图像设置为模板。但这些方法都没有真正起作用。
到目前为止,感谢您的回答。
编辑: 按钮的图像应该只是一个简单的 pdf。渐变和白色阴影应该自动绘制。
How can I create a iPhoto like button like in the picture
I've tried out several things using round textured buttons or setting the button's image as template. But none of these approaches really works.
Thanks so far for your answers.
EDIT:
The image of the button should just be a simple pdf. The gradient and the white shadow should be drawn automatically.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
正如 Justin 提到的,您应该创建一个 Momentary Change 类型的
NSButton
。然后,您应该通过在文件名中包含后缀 Template 来表明它是模板图像,例如EditTemplate.png
。我知道您说过您尝试将图像设置为模板,但我发现如果我不使用瞬时更改按钮类型,这并不总是有效。
As Justin mentioned you should create an
NSButton
with type Momentary Change. You should then indicate that it is a template image by including the suffix Template in the filename, e.g.EditTemplate.png
.I know you said you tried setting the image as template, but I found that this wasn't always effective if I wasn't using the Momentary Change button type.
您可以子类化 NSButtonCell。并实现这些功能:
要设置子类,只需将 Interface Builder 中按钮单元的“自定义类”字段从“NSButtonCell”编辑为“YourSubClass”
You could subclass NSButtonCell. And implement these functions:
To setup the subclass just edit the "Custom Class" field of the Button Cell in Interface Builder from "NSButtonCell" to "YourSubClass"
我认为最简单的解决方案是创建类型为:瞬时更改的按钮,并在其上添加带有 .png 类型文件的透明背景图像,当按钮打开时,您可以更改为其他带背景的图片。
例如设置/更改图像:
如果我正确理解了您想要做什么。
I think the simplest solution is to create button with type: Momentary Change and add on it image with transparent background with .png type of file and when button is ON You can change to other picture with background.
For example to set/change image:
If I have understood correctly what You want to do.