ios - addAttribute不起作用
PHPz
PHPz 2017-04-18 09:41:05
0
2
583

我想用这段代码将我选中的textview中的内容更改一个字体,但是没有起作用。大神们知道为什么么?

let string = NSMutableAttributedString(string: bodyView.inputBodyTV.text)
string.addAttribute(NSFontAttributeName, value: UIFont.boldSystemFontOfSize(15), range: selecteRange)
PHPz
PHPz

学习是最好的投资!

reply all(2)
伊谢尔伦
  1. Check if selecteRange is correct

  2. Use textView.attributedText, not textView.text

  3. After modification, you need to reassign textview

洪涛

+1 from upstairs, use textView.attributedText, not textView.text

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!