当前位置: 动力学知识库 > 问答 > 编程问答 >

ios - how can i get the fonts attributed

问题描述:

i've a single UIButton to set the text bold and unbold in UITextview

 let range = mainTextView.selectedRange

let string = NSMutableAttributedString(attributedString: mainTextView.attributedText)

let attributes = [NSFontAttributeName: UIFont.boldSystemFontOfSize(12)]

string.addAttributes(attributes, range: mainTextView.selectedRange)

mainTextView.attributedText = string

My question is how to unbold the selected text if it is already bold? how to check if the selectedRange is already bold or not?

分享给朋友:
您可能感兴趣的文章:
随机阅读: