let paragraphStyle = NSMutableParagraphStyle()
paragraphStyle.lineSpacing = 15
// 字体的行间距
let attributes = [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 14), NSAttributedStringKey.paragraphStyle: paragraphStyle]
self.textView.typingAttributes = attributes.toTypingAttributes()
MARK:- 扩展字典
extension Dictionary where Key == NSAttributedStringKey {
func toTypingAttributes() -> [String: Any] {
var convertedDictionary = [String: Any]()
for (key, value) in self {
convertedDictionary[key.rawValue] = value
}
return convertedDictionary
}
}