0
大家好我有一個UILabel與lineHeight 1.2,需要它是多彩的,但只要我改變文本的顏色,lineheight的值就成爲默認值。 這裏是我的功能:UILabel的多色着色與保存lineHeight
func configTopLabel(label: UILabel, localString: String, color: UIColor) {
var myString:NSString = localString
var myMutableString = NSMutableAttributedString()
myMutableString = NSMutableAttributedString(string: myString as String, attributes: [NSFontAttributeName:UIFont(name: "GothamPro-Bold", size: 22.0)!])
let location = localString.characters.count - 3
myMutableString = NSMutableAttributedString(string: myString as String, attributes: [NSFontAttributeName:UIFont(name: "GothamPro-Bold", size: 22.0)!])
myMutableString.addAttribute(NSForegroundColorAttributeName, value: color, range: NSRange(location: location,length: 3))
label.setLineHeight(1.2)
label.attributedText = myMutableString
}
'setLineHeight'是如何實現的? – dan