6

I have a UITabBarController. It has two tabs. They are labelled "FirstTitle" and "SecondTitle." How can I find out what the default font size for these titles are?

In ViewDidLoad, for my first View Controller, which corresponds to my first tab, I have tried:

print(self.tabBarController?.tabBar.items?[0].titleTextAttributes(for: 
.normal))
print(self.tabBarController?.tabBar.items?[0].titleTextAttributes(for: 
.selected))
let appearance = UITabBarItem.appearance()
print(appearance.titleTextAttributes(for: .normal))

All of these return "nil." In addition, there is no default font size for the tab bar shown anywhere in Main.storyboard.

Everett
  • 387
  • 1
  • 4
  • 17

1 Answers1

6
  1. Break the program with Debug View Hierarchy button
  2. Select the UITabBarButtonLabel of your choice
  3. Open the Object inspector
  4. Discover that on iOS 12, the default is:

    the system font (San Francisco) with a size of 10 and a weight of medium.

You also have the color, alignment and other useful informations.

enter image description here

Cœur
  • 37,241
  • 25
  • 195
  • 267