【问题标题】:how to change the color of a rounded button image programmatically in an iPhone/IOS application?如何在 iPhone/IOS 应用程序中以编程方式更改圆形按钮图像的颜色?
【发布时间】:2011-11-11 00:04:12
【问题描述】:

我使用圆形图像为 UITableViewController 中的单元格创建(在 iPhone 中)圆形按钮效果。

问题 - 有没有办法以编程方式更改圆形单元格的背景区域,这基本上是我正在使用的圆形 UIImage?也就是圆边区域外没有颜色溢出?

(即当前颜色被有效地硬编码到图像中,希望为用户提供能够选择他们想要的颜色的能力)

【问题讨论】:

标签: iphone ios uiimageview uiimage background-color


【解决方案1】:
Try this code its definitely help you.

CALayer *layer = [<yourimageview> layer];
[layer setMasksToBounds:YES];
[layer setCornerRadius:5.0];

【讨论】:

    【解决方案2】:

    图像处理可以参考OpenCV,可以改变颜色。

    OpenCV

    希望对你有帮助。

    【讨论】:

    • 嗨,Parth - 您是否碰巧知道我正在尝试做的事情是否可以在不使用第三方库的情况下实现?即只坚持核心 IOS 类库等?
    • @Greg:老实说,我不确定这对于核心 iOS 库是否可行。 :)
    猜你喜欢
    • 2020-05-22
    • 2010-12-21
    • 2023-03-31
    • 2011-01-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-30
    • 2012-11-19
    相关资源
    最近更新 更多