UIBarButtonItem setTintColor doesn't work on iOS7

后端 未结 2 2019
天涯浪人
天涯浪人 2021-01-20 05:49

In iOS6, I used this code to make my UIBarButtonItem:

UIBarButtonItem* validate = [[UIBarButtonItem alloc]initWithTitle:@\"MyTitle\" style:UIBarButtonItemSty         


        
相关标签:
2条回答
  • 2021-01-20 06:32

    In iOS7 you if you need to change the navigationBar buttons color, you must set tintColor for the navgationBar not the for specific barButton any more.

    navigationController.navigationBar.tintColor = [UIColor orangeColor];
    

    Edit: this works in iOS7, you need to do the check:

    float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];
    if (systemVersion >= 7.0)
    {
        navigationController.navigationBar.tintColor = [UIColor orangeColor]
    }
    
    0 讨论(0)
  • 2021-01-20 06:32

    I couldn't get @Chris's method to work (iOS 8 like @Adama says).

    My use case is that I want to set all UIToolbar & UINavigationBar buttons to a default colour. So using the UIAppearance API:

    UIBarButtonItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName : UIColor.redColor()], forState: .Normal)

    0 讨论(0)
提交回复
热议问题