我想改变所有应用程序的NavigationControl后退按钮的颜色,我该怎么办?我希望用红色代替普通的蓝色按钮......
我的TabBar有问题。 我已将图标颜色和名称从标准蓝色更改为红色:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.redColor()], forState:.Selected)
这个
class TabBarController: UITabBarController {
var color = UIColor.redColor()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
self.tabBarController?.tabBar.selectedImageTintColor = UIColor.redColor()
UITabBar.appearance().selectedImageTintColor = UIColor.redColor()
但是我有超过5个标签,所以我有“更多”按钮,当我按下它时,图标不是红色而是蓝色,当我按下编辑标签栏图标时,名称选项卡为红色,但图标不是。 我能做什么? 图片解释: http://postimg.org/image/67oqa15ll/
答案 0 :(得分:7)
在整个应用程序中更改所有UITabBarItem的文本和图标颜色(在Swift / Xcode 6中):
在AppDelegate.swift中:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: your_color ], forState: .Selected)
UITabBar.appearance().tintColor = your_color
return true
}
这就行了!
答案 1 :(得分:1)
在firstViewController中尝试这个
class ViewController: UIViewController,UITabBarDelegate, UITabBarControllerDelegate, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
UITabBar.appearance().tintColor = UIColor.redColor()
var view: UITableView = self.tabBarController?.moreNavigationController.topViewController.view as UITableView
view.tintColor = UIColor.redColor()
if view.subviews.count != 0 {
for cell in view.visibleCells() {
cell.textLabel??.textColor = UIColor.redColor()
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
,这在你的UITabbarController
中class TabbarViewController: UITabBarController,UITabBarDelegate, UITabBarControllerDelegate, UINavigationControllerDelegate {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tabBar(tabBar: UITabBar, didBeginCustomizingItems items: [AnyObject]) {
self.view.tintColor = UIColor.redColor()
}
}
示例项目https://www.dropbox.com/s/kbm4l60cnvyrf5h/UItabbarCustomizing.zip?dl=0
我希望我能帮到你