iOS 11:输入时UITextView typingAttributes重置 [英] iOS 11: UITextView typingAttributes reset when typing

查看:1468
本文介绍了iOS 11:输入时UITextView typingAttributes重置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 typingAttributes 来设置新字体。在 iOS 10 上,一切正常,但在 iOS 11 上,第一个输入的字符是正确的,但是属性正在重置为之前的属性,第二个字符是键入的以前的字体。这是一个错误吗?我能以某种方式修复它吗?

解决方案

我遇到了同样的问题,最终通过在每次编辑后再次设置typingAttributes来解决它。 / p>

Swift 3

  func textViewDidChange( _ textView:UITextView){
NotesTextView.typingAttributes = [NSForegroundColorAttributeName:UIColor.blue,NSFontAttributeName:UIFont.systemFont(ofSize:17)]
}


I use typingAttributes to set a new font. On iOS 10, everything works, but on iOS 11, first typed character is correct, but then attributes are being reset to the previous ones, and the second character is typed with the previous font. Is this a bug? Can I fix it somehow?

解决方案

I ran into the same issue and eventually solved it by setting typingAttributes again after every edit.

Swift 3

func textViewDidChange(_ textView: UITextView) {
    NotesTextView.typingAttributes = [NSForegroundColorAttributeName: UIColor.blue, NSFontAttributeName: UIFont.systemFont(ofSize: 17)]
}

这篇关于iOS 11:输入时UITextView typingAttributes重置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆