Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有人知道如何为 UIButton (iphone) 着色吗?我有一个带有 alpha 的灰度图像,我想将其着色为各种不同的颜色。设置诸如背景颜色之类的东西只会对整个图像进行着色而不考虑 alpha。
有没有一种简单的方法可以做到这一点,或者我是否需要继承 UIButton 并重载 drawRect 方法?谢谢。
一种选择是使用 one-segment UISegmentedControl,它提供对 tint 属性的访问。这些可以像UIButton具有正确设置的 a 一样表现,并且看起来很像 Apple 用于其 iPhone 应用程序的玻璃样式。
UISegmentedControl
UIButton