Swift无法更改标签栏的字体

时间:2019-04-29 20:59:29

标签: ios swift uitabbaritem uiappearance

我的应用程序正在使用标签栏。我更改了appdelegate中选项卡栏项目的颜色。现在,我正在尝试更改字体,但是它不起作用,而且我似乎无法找出原因。

这是我在didFinishLaunchingWithOptions中的AppDelegate中拥有的内容:

感谢您的快速回答,这里是完整代码的样子:

import UIKit
import IQKeyboardManager

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        UITabBarItem.appearance()
            .setTitleTextAttributes(
                [NSAttributedString.Key.font: UIFont(name: "Didot", size: 10)!],
                for: .normal)
        UINavigationBar.appearance().shadowImage = UIImage()
        UINavigationBar.appearance().setBackgroundImage(UIImage(), for: UIBarMetrics.default)
        UINavigationBar.appearance().isTranslucent = true
 UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: #colorLiteral(red: 0.3999382854, green: 0.5484475493, blue: 0.3402945399, alpha: 1)], for: .normal)
        UITabBar.appearance().tintColor = #colorLiteral(red: 0.3999382854, green: 0.5484475493, blue: 0.3402945399, alpha: 1)
        UITabBar.appearance().unselectedItemTintColor = .white

        return true
    }
}

0 个答案:

没有答案