【发布时间】:2017-03-23 12:27:03
【问题描述】:
我有一个具有背景颜色和圆角的可变文本。所以我将 UILabel 与 NSMutableAttributedString 一起使用。
myAttributedString = NSMutableAttributedString(string:"hello")
myAttributedString.addAttribute(NSBackgroundColorAttributeName, value: UIColor.red, range: NSRange(location: 0, length: myAttributedString.length))
myLabel.attributedText = myAttributedString
myLabel.layer.cornerRadius = 5
myLabel.clipsToBounds = true
myLabel.layer.masksToBounds = true
我得到一个只有一侧有圆角的标签。我应该怎么做才能得到四面八方的圆角?
【问题讨论】:
-
@karthikeyan 我已经添加了cornerRadius 和 masktoBounds,也尝试添加 sizeToFit ......但我得到了相同的结果,
-
问题出在其他地方,您是否使用 uibeizerpath 作为标签
-
@Anbu.Karthik nope
-
没问题不在这一行
标签: ios swift3 uilabel nsmutableattributedstring