我有一个多行 UILabel,我想将其背景颜色设置为与您用鼠标在网络浏览器上突出显示文本时完全相同,但似乎找不到解决方案。
这就是我的目标:
最佳答案
是的,使用属性文本。此处为 swift
let textBgColor = UIColor.greenColor()
let attributes = [
NSBackgroundColorAttributeName : textBgColor
]
let attributedString = NSAttributedString(string: Constant.kDescriptionArray[0], attributes: attributes)
descriptionLabel.attributedText = attributedString
关于ios - swift 的 iOS。多行 UILabel 背景颜色跟随文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38068228/