Ios 如何在UITextview中通过单词包装NSTextAttachment进行换行
我使用UITextview并将NSTextAttachment作为图像插入其中。该文本视图只有附件图像,没有任何普通文本。如何像普通文本一样换行。我已设置textContainer的lineBreakMode属性,但不起作用。我将感谢你的任何帮助Ios 如何在UITextview中通过单词包装NSTextAttachment进行换行,ios,swift,text,uitextview,nstextattachment,Ios,Swift,Text,Uitextview,Nstextattachment,我使用UITextview并将NSTextAttachment作为图像插入其中。该文本视图只有附件图像,没有任何普通文本。如何像普通文本一样换行。我已设置textContainer的lineBreakMode属性,但不起作用。我将感谢你的任何帮助 func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { r
func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool {
return true
for data in arrDataModel {
if data.textDefaul == text {
let attachment = NSTextAttachment()
if let image = data.imageData {
let imageNew = UIImage(data: image)!
attachment.image = imageNew.colorImage(with: colorDefault)
}else{
return true
}
let attString = NSAttributedString(attachment: attachment)
var attributedString :NSMutableAttributedString!
attributedString = NSMutableAttributedString(attributedString:textView.attributedText)
attributedString.insert(attString, at: textView.selectedRange.location)
textView.attributedText = attributedString
textView.selectedRange.location += 1
return false
}
}
return true
}