1

I have a ViewController.

I added a Title to the Viewcontroller.

Its a variable.

 var Title: String! = ""


    override func viewDidLoad() {
        super.viewDidLoad()


      self.title = Title
}

Is there a way, to make the font bigger?

Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
iFiWi
  • 13
  • 1
  • 4

3 Answers3

9

This way you can customise your navigation title:

self.title = ""
var attributes = [NSFontAttributeName: UIFont(name: "Avenir", size: 20)!] //change size as per your need here.
self.navigationController?.navigationBar.titleTextAttributes = attributes
Dharmesh Kheni
  • 71,228
  • 33
  • 160
  • 165
1
Make a Title View Label and assign it to the navigation item. 

code for it is:

var tlabel = UILabel(frame: CGRectMake(0, 0, 300, 40))
tlabel.text = self.navigationItem.title;
tlabel.textColor = UIColor.whiteColor()
tlabel.backgroundColor = UIColor.whiteColor()
tlabel.adjustsFontSizeToFitWidth = true
self.navigationItem.titleView = tlabel
0

Here is the possible work around. You can assign any UIView to a navcontroller's title area.

Create a UILabel and set its font and size anyway you want, then assign it to the UIViewController's navigationItem.titleView property. Make sure the UILabel's backgroundColor is set to clearColor.

UILabel *labelTitle = UILabel(frame: CGRectZero);
labelTitle.text = "Title";

labelTitle.font = UIFont(name: "Your-Font-Name", size: SIZE)

labelTitle.text.textAlignment = NSTextAlignment.Center
self.navigationItem.titleView = labelTitle;
Niraj
  • 1,939
  • 20
  • 29