繁体   English   中英

如何为NSAttributedString的背景设置转角半径?

[英]How to set a corner radius for NSAttributedString's background?

我想为UILabel上的部分文本设置拐角半径。 我有范围。
以下代码设置了背景颜色,但它将是矩形背景。

那么,我的问题是如何设置拐角半径

string.setAttributes([NSBackgroundColorAttributeName: UIColor.red], range: range)

感谢您的任何建议。

yourLabel.layer.backgroundColor  = UIColor.redColor().CGColor
yourLabel.layer.cornerRadius = 5  //Change this value as your requirement
yourLabel.layer.masksToBounds = true

愿这段代码对您有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM