2016-01-15 3 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

Это просто [Self-ответ] (HTTP: //stackoverflow.com/help/self-answer) – lifeisfoo

Смежные вопросы