簡體   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