【发布时间】:2018-09-22 11:08:16
【问题描述】:
以下是添加属性字符串背景颜色的示例代码,但我想为图像设置标签属性字符串颜色。有没有办法做到这一点?
let attributedString = NSMutableAttributedString(string:text!)
attributedString.addAttribute(NSAttributedStringKey.backgroundColor, value: UIColor.red , range: range)
【问题讨论】:
-
你想给 UIImage 添加背景颜色,你可以使用 UIImageView.background color 属性
-
您的描述不清楚。你想给图像着色吗?
-
@ReinierMelian:您好,我想添加标签特定文本的背景图片
-
您的问题仍然模棱两可。我的理解是您想使用图像作为文本的背景(此文本在标签中)。对吗?
标签: ios swift swift3 swift4 nsattributedstring