У меня есть UIButton. В конструкторе интерфейсов я установил его название как "Атрибут". Как сделать так, чтобы его заголовок подчеркивался из кода в Swift?
@IBOutlet weak var myBtn: UIButton!
Я создал функцию, вызываемую для события touchUpInside этой кнопки:
var attributedString = NSMutableAttributedString(string:"new text")
var attrs = [
NSFontAttributeName : UIFont.systemFontOfSize(19.0),
NSForegroundColorAttributeName : UIColor.redColor()
]
var gString = NSMutableAttributedString(string:"g", attributes:attrs)
attributedString.appendAttributedString(gString)
myBtn.titleLabel?.attributedText = attributedString;
Но до сих пор нет результата. Также мне нужно знать, как получить доступ к атрибуту подчеркивания. Текст, размер и цвет остаются неизменными.