为 UI 按钮着色
有人知道如何为 UIButton (iphone) 着色吗?我有一个带有 alpha 的灰度图像,我想将其着色为各种不同的颜色。设置诸如背景颜色之类的东西只会对整个图像进行着色,而不考虑 Alpha。
有没有一种简单的方法可以做到这一点,或者我是否需要子类化 UIButton 并重载 drawRect 方法?谢谢。
Does someone know how to colorize a UIButton (iphone)? I have a greyscale image with alpha that I want to colorize to various different colors. Setting things like background color only shade the entire image without respecting the alpha.
Is there a straightforward way to do this, or will I need to subclass UIButton and overload the drawRect method perhaps? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种选择是使用单段
UISegmentedControl
,它提供对色调属性的访问。如果设置正确,它们的行为就像UIButton
一样,而且看起来很像 Apple 用于 iPhone 应用程序的玻璃样式。One option is to use a one-segment
UISegmentedControl
, which provides access to a tint property. These can behave like aUIButton
with the right settings, and look a lot like the glass-style that Apple uses for its iPhone apps.