Roi Mulia
Roi Mulia

Reputation: 5896

Changing UINavigationBar Font Type while keeping the default size

I know that for changing the font of UINavigationBar he will simply do

self.navigationController!.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "MavenProBold", size: 15)!, NSForegroundColorAttributeName: UIColor.whiteColor()]

Tho, i'm trying to change only the font type, and keeping iOS default font size(which i guess he is dynamic among the devices). Any suggestions?

Upvotes: 1

Views: 144

Answers (1)

dokun1
dokun1

Reputation: 2110

If you change the font type, you will have to specify a font size. Generally you have to do this manually.

If you want to match the size of another font you see, say in another UILabel, you could do:

CGFloat fontSize = self.label.font.pointSize; // obj-c
let fontSize = CGFloat(label.font.pointSize) // swift

And then assign the size of the font you are setting to be this.

UPDATE

After thorough investigation, the common font size of the UINavigationBar is 34px, which is 17 in your Xcode editor. Remember that you can manually override this view, but that is the default font size.

Upvotes: 1

Related Questions