解决方法
如果您如此倾向,可以尝试解析
Kern Table并修改UIFont / CFFont以满足您的需求.我不是字体设计师,所以我只需要在标签上添加一个观察者,并观察是否发生.4以应用字距调整.
override func viewDidLoad() { super.viewDidLoad() self.label.addObserver(self,forKeyPath: "text",options: [.New],context: nil) } override func observeValueForKeyPath(keyPath: String?,ofObject object: AnyObject?,change: [String : AnyObject]?,context: UnsafeMutablePointer<Void>) { if object === self.label,let change = change,let newValue = change[NSKeyValueChangeNewKey] as? NSString,let attributedText = self.label.attributedText?.mutableCopy() as? NSMutableAttributedString { let matchRange = newValue.rangeOfString(".4") if matchRange.location == NSNotFound { attributedText.removeAttribute(NSKernAttributeName,range: NSMakeRange(0,newValue.length)) } else { let kernRange = NSMakeRange(matchRange.location,matchRange.length - 1) attributedText.setAttributes([NSKernAttributeName: 10],range: kernRange) } self.label.attributedText = attributedText } }