Swift4.0 - 设置TabBarItem的属性

   self.tabBar.barStyle = UIBarStyle.default
    //设置tabBar是否透明
    self.tabBar.isTranslucent = true
    self.tabBar.tintColor = UIColor.white

    //设置tabBarItem的title,以及点击和不点击状态图片
    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 12), NSAttributedString.Key.foregroundColor : UIColor.darkGray], for: .normal)

    //设置tabBarItem的title的字体颜色和字大小及字体样式 
    UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font : UIFont.systemFont(ofSize: 12), NSAttributedString.Key.foregroundColor : UIColor.red], for: .selected)

你可能感兴趣的:(Swift4.0 - 设置TabBarItem的属性)