我想给 textView 添加行间距。使用以下代码,我收到错误消息“textView 没有成员属性文本”。 我该如何解决这个问题?
import UIKit
@objc protocol TextViewCellProtocol:NSObjectProtocol {
func textViewCellDidTouchedButton(_ cell:TextViewCell)
}
class TextViewCell: UICollectionViewCell {
@IBOutlet var textView:FuriganaTextView!
let style = NSMutableParagraphStyle()
style.lineSpacing = 40
let attributes = [NSParagraphStyleAttributeName : style]
textView.attributedText = NSAttributedString(string: textView.text,
attributes: attributes)
}
最佳答案
我相信您收到错误是因为您正在使用的 textView 类 (FuriganaTextView
) 没有成员 attributedText
。检查他们的gitHub documentation后.我想您可以通过将属性字符串指定到 FuriganaTextView
的 contents
属性来将属性文本添加到 FuriganaTextView
,例如
textView.contents = NSAttributedString(string: textView.text,
attributes: attributes)
关于ios - 将行间距添加到 textView 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46067907/