Swift3 NSTEXT附件周围的间距

Swift3 NSTEXT附件周围的间距,swift3,uitextview,nsattributedstring,nstextattachment,Swift3,Uitextview,Nsattributedstring,Nstextattachment,如何在NSTextAttachments周围设置间距,如下面的示例所示 在本例中,当我将NSTextAttachment附加到NSAttributedString时,没有空格是默认行为 这在Swift中对我很有效 public extension NSMutableAttributedString { func appendSpacing( points : Float ){ // zeroWidthSpace is 200B let spacin

如何在NSTextAttachments周围设置间距,如下面的示例所示

在本例中,当我将NSTextAttachment附加到NSAttributedString时,没有空格是默认行为


这在Swift中对我很有效

public extension NSMutableAttributedString {    
    func appendSpacing( points : Float ){
        // zeroWidthSpace is 200B
        let spacing = NSAttributedString(string: "\u{200B}", attributes:[ NSAttributedString.Key.kern: points])
        append(spacing)
    }
}

添加空格,还是添加NSKernerAttributeName?没有默认的空格,就像一个接一个地写两个字母,但不是字母而是图像。我尝试了NSKernAttributeName,但它不起作用。在它们之间添加
NSAttributeString*space=[[NSAttributeString alloc]initWithString:@”“]
?像上面建议的那样,空格不会给出任何精度,但它确实起到了快速而丑陋的修复作用。
public extension NSMutableAttributedString {    
    func appendSpacing( points : Float ){
        // zeroWidthSpace is 200B
        let spacing = NSAttributedString(string: "\u{200B}", attributes:[ NSAttributedString.Key.kern: points])
        append(spacing)
    }
}