Вот текст:
@IBOutlet weak var legalText: UITextView!
let textToAppend = "TERMS OF SERVICE\nLast Updated: May 7, 2015\n\nPLEASE NOTE: The HIGO Terms of Service as stated below is effective as of the 'Last Updated' date above for any user who is browsing the HIGO website, or for any user who creates a HIGO account on or after that date."
legalText.text = legalText.text.stringByAppendingString(textToAppend)
Я хочу выделить "УСЛОВИЯ ОБСЛУЖИВАНИЯ" и "ПОЖАЛУЙСТА, ОБРАТИТЕ ВНИМАНИЕ: Условия обслуживания HIGO, как указано ниже, действуют с даты" Последнее обновление "выше для любого пользователя, просматривающего веб-сайт HIGO или для любого пользователя который создает учетную запись HIGO после или после этой даты".
Я пытаюсь использовать uilabel программно в uitextview, но не работает:
var termsofservice : UILabel = UILabel()
termsofservice.numberOfLines = 0
termsofservice.text = "TERMS OF SERVICE"
termsofservice.font = UIFont.boldSystemFontOfSize(20)
termsofservice.textAlignment = NSTextAlignment.Left;
var pleasenote : UILabel = UILabel()
pleasenote.numberOfLines = 0
pleasenote.text = "PLEASE NOTE: The HIGO Terms of Service as stated below is effective as of the 'Last Updated' date above for any user who is browsing the HIGO website, or for any user who creates a HIGO account on or after that date."
pleasenote.font = UIFont.boldSystemFontOfSize(20)
pleasenote.textAlignment = NSTextAlignment.Left;
let textToAppend = "\(termsofservice)\nLast Updated: May 7, 2015\n\n\(pleasenote)"
также попробуйте с ними, но не работает, он показывает только "УСЛОВИЯ ОБСЛУЖИВАНИЯ" и "последнее обновление..", не показывал "ПОЖАЛУЙСТА ЗАМЕТЬТЕ..."
var termsofservice = "TERMS OF SERVICE"
var normalText = "\n\nLast Updated: May 7, 2015"
var pleasenote = "\n\nPLEASE NOTE: The HIGO Terms of Service as stated below is effective as of the 'Last Updated' date above for any user who is browsing the HIGO website, or for any user who creates a HIGO account on or after that date."
var attributedString = NSMutableAttributedString(string:normalText)
var attrs = [NSFontAttributeName : UIFont.boldSystemFontOfSize(15)]
var boldString = NSMutableAttributedString(string:pleasenote, attributes:attrs)
var boldString0 = NSMutableAttributedString(string:termsofservice, attributes:attrs)
boldString0.appendAttributedString(attributedString)
attributedString.appendAttributedString(boldString)
legalText.attributedText = boldString0
Как выделять эту часть строки?
Примечание: текст по-прежнему длинный и содержит большую часть строки, выделенной жирным шрифтом.