ibireme / YYText

Powerful text framework for iOS to display and edit rich text.
MIT License
8.84k stars 1.68k forks source link

删除单词末尾最后一个字符,键盘默认变成大写输入 #943

Open JonathanChen123 opened 3 years ago

JonathanChen123 commented 3 years ago

删除单词末尾最后一个字符,键盘默认变成大写输入。

比如输入“Hello thr”,删除最后一个r时,键盘会自动切换到大写输入。

iPhoneX iOS14.2

public lazy var textView: YYTextView = {

    let textView = YYTextView()

    var placeholder = "Comment"

    let infoString = UserDefaults.LoginInfo.value(forKey: .userInfo) as? String

    if let data = infoString?.data(using: .utf8) {
        if let info = try? JSON(data: data) {
            if let nick_name = info["nick_name"].string {
                placeholder = placeholder + " as " + nick_name
            }
        }
    }

    textView.tintColor = TSApprearance.Colors.theme
    textView.textAlignment = .left
    textView.placeholderAttributedText = NSMutableAttributedString(string: placeholder, attributes: [NSAttributedString.Key.font: UIFont.avenirRoman(size: 12.0), NSAttributedString.Key.foregroundColor: UIColor(65.0, 65.0, 65.0, 0.4)])
    textView.font = .avenirRoman(size: 12.0)
    textView.textContainerInset = UIEdgeInsets(top: 13.0, left: -3.0, bottom: 13.0, right: -3.0)
    textView.textColor = TSApprearance.Colors.Text.black
    textView.allowsCopyAttributedString = false

    return textView
}()