0

I'm not seeing anything here on text kerning for the navigation bar. Anyone know how to do this? I have set up the text in ViewDidLoad()

 self.navigationController?.navigationBar.topItem?.title = "My Nav Title"
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Helvetica", size: 20)!, NSForegroundColorAttributeName: UIColor.whiteColor()]

I see we can adjust kerning but can't get this code to work

attributes: [NSKernAttributeName: 5.0]

Thank Much!!!

Westsider
  • 145
  • 12

1 Answers1

0

I found and modified this code from an earlier post and it works now in xcode 7.3.1

    let titleLabel = UILabel()

    let attributes: NSDictionary = [
        NSFontAttributeName:UIFont(name: "Helvetica", size: 20)!,
        NSForegroundColorAttributeName:UIColor.blackColor(),
        NSKernAttributeName:CGFloat(8.0)
    ]

    let attributedTitle = NSAttributedString(string: ""My Nav Title", attributes: attributes as? [String : AnyObject])

    titleLabel.attributedText = attributedTitle
    titleLabel.sizeToFit()
    self.navigationItem.titleView = titleLabel
Westsider
  • 145
  • 12