codeman codeman - 2 years ago 192
Swift Question

iOS 8 - change character spacing on UILabel within Interface Builder

Is there anyway to change the character spacing (track) on UILabel text using Interface Builder? If not, is there a way to do it programmatically on an existing UILabel that was already created with attributed text?

Answer Source

Ended up using this for now to get existing attributed text and modify to add character spacing:

let attributedString = discoveryTitle.attributedText as NSMutableAttributedString
attributedString.addAttribute(NSKernAttributeName, value: 1.0, range: NSMakeRange(0, attributedString.length))
discoveryTitle.attributedText = attributedString
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download