2
我想爲UILabel上的部分文本設置一個圓角半徑。我有範圍。
下面的代碼設置背景顏色,但它會是一個矩形背景。如何爲NSAttributedString的背景設置角半徑?
那麼,我的問題是如何設置一個圓角半徑呢?
string.setAttributes([NSBackgroundColorAttributeName: UIColor.red], range: range)
謝謝你的任何建議。
我想爲UILabel上的部分文本設置一個圓角半徑。我有範圍。
下面的代碼設置背景顏色,但它會是一個矩形背景。如何爲NSAttributedString的背景設置角半徑?
那麼,我的問題是如何設置一個圓角半徑呢?
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
願這段代碼能幫助你。
此代碼是對於標籤上的圓角設置不適用於字符串,所以請不要發佈這種類型的錯誤答案。 –
你可以添加一些aditional代碼 –
可能重複的[NSAttributedString背景顏色和圓角](https://stackoverflow.com/questions/16362407/nsattributedstring-background-color-and-rounded-corners) – BJHStudios