1
我试图使用NSTextAttachment
在UITextField
中显示图像,但我希望图像和文本之间有一定的水平间距。但是,如下所示将NSKernAttributeName
属性添加到属性字符串时,会将附件的高度重置为与周围文本相同的高度。NSTextAttachment的水平间距
var str = NSMutableAttributedString(attributedString: NSAttributedString(attachment: imageAttachment))
str.addAttribute(NSKernAttributeName, value: 10, range: NSRange(location: 0,length: 1))
是否有另一种方法来添加图像和文本之间的水平空间?