How do you adjust text kerning using Interface Builder in Xcode 7?

后端 未结 5 1746
無奈伤痛
無奈伤痛 2021-02-13 18:33

There are a myriad of settings for NSAttributedParagraphStyle that I can see in Interface Builder:

5条回答
  •  走了就别回头了
    2021-02-13 18:51

    A shortened attempt:

    @IBDesignable class KerningLabel: UILabel {
    
    
      @IBInspectable var kerning: CGFloat = 0.0 {
        didSet {
          let attrStr = NSMutableAttributedString(string: "Foobar")
          attrStr.addAttributes([NSKernAttributeName: kerning],
                                range: NSMakeRange(0, attrStr.string.characters.count))
          attributedText = attrStr
        }
      }
    }
    

提交回复
热议问题