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.
在 Objective C 中,对于 iPhone/iPad 我正在努力尝试在 UIButton 中更改 UIImage 的颜色(红色/黄色/绿色)。如何才能做到这一点。是否需要子类?有人可以提供一个例子。
即这是一个完整的单色叠加。
如果您想在 UIButton 顶部放置一个半透明图像蒙版(这不会完全改变颜色,但可以添加彩色阴影效果),然后创建一个半透明 PNG,将其添加到您的支持文件组,然后在某个地方添加以下代码行,例如viewDidLoad视图控制器以在 UIButton 顶部添加掩码:
viewDidLoad
[myButton addSubview:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"overlay.png"]]];