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?
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?
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
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
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;