horshoo
horshoo
发布于 3周前

Swift更改UITabBarItem的字体

主要是使用UItabBarItem的attribute keys来设置字体:

Swift 4

UITabBarItem.appearance()
    .setTitleTextAttributes(
        [NSAttributedStringKey.font: UIFont(name: "Didot", size: 10)!], 
    for: .normal)

Swift 3

UITabBarItem.appearance()
   .setTitleTextAttributes(
       [NSFontAttributeName: UIFont(name: "Font-Name", size: 10)!], 
   for: .normal)