Ios 如何为NSAttributedString设置角半径';她有什么背景?

Ios 如何为NSAttributedString设置角半径';她有什么背景?,ios,uilabel,core-text,Ios,Uilabel,Core Text,我想为UILabel上的部分文本设置一个角半径。我有这个范围。 下面的代码设置了背景颜色,但它将是一个矩形背景 因此,我的问题是如何为其设置角半径 string.setAttributes([NSBackgroundColorAttributeName: UIColor.red], range: range) 谢谢你的建议 yourLabel.layer.backgroundColor = UIColor.redColor().CGColor yourLabel.layer.cornerRa

我想为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
希望这段代码能对你有所帮助


希望这段代码能对你有所帮助。

你能添加一些传统代码吗