我更改字距调整后,样式会重置。例如,当我更改文本大小或颜色时,将保存它,但是当我更改字距调整时,将重置UITextView样式。
@IBAction func sizeTextEdit(_ sender: Any) { self.textOne?.font = UIFont.systemFont(ofSize: CGFloat(sizeText.value * 1)) } @IBAction func kernTextEdit(_ sender: Any) { let textString = textOne.text let attrs: [NSAttributedString.Key : Any] = [.kern: kernText.value] textOne?.attributedText = NSAttributedString(string: textString!, attributes: attrs) }
正如您在第一个屏幕截图中所看到的,我增加了字体,然后增加了字母之间的距离,并且重新设置了字体大小
我更改字距调整后,样式会重置。例如,当我更改文本大小或颜色时,将保存它,但是当我更改字距调整时,将重置UITextView样式@IBAction func sizeTextEdit(_ sender:...
font
属性仅更改text
属性的字体。 attributedText
是一个不同的属性,因此您也需要为其定义font
: