2016-01-15 81 views

回答

8

假设你希望有一个这样的小灰货币符号:

enter image description here

只需使用一个NSMutableAttributedString对象:

let amountText = NSMutableAttributedString.init(string: "€ 60,00") 

// set the custom font and color for the 0,1 range in string 
amountText.setAttributes([NSFontAttributeName: UIFont.systemFontOfSize(12), 
           NSForegroundColorAttributeName: UIColor.grayColor()], 
         range: NSMakeRange(0, 1)) 
// if you want, you can add more attributes for different ranges calling .setAttributes many times 

// set the attributed string to the UILabel object 
myUILabel.attributedText = amountText 
+5

这只是一个[自答案】(HTTP: //stackoverflow.com/help/self-answer) – lifeisfoo

相关问题