UIBarButtonItem Title Text is Always Global Tint Color

Xander Dunn

iOS 7.0 and up.

In AppDelegate.m, I'm setting my global tintColor: self.window.tintColor = myGlobalTintColor;.

In my table view controller where I want a red trash can button in the navigation bar while editing the table view cells, I have this:

- (void)setEditing:(BOOL)editing animated:(BOOL)animate {
    [super setEditing:editing animated:animate];
    if (editing) { // Start editing
        self.deleteBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteButtonPressed)];
        [self.deleteBarButtonItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor redColor],  NSForegroundColorAttributeName, nil] forState:UIControlStateNormal];
        self.navigationItem.rightBarButtonItems = @[self.deleteBarButtonItem];
    }
}

Despite the line of code that is setting NSForegroundColorAttributeName to [UIColor redColor], I never see the red color. When the button it set to .enabled = YES, I simply see it in my global tint color, like all the other buttons: UINavigationBar with always tinted UIBarButtonItem

I've combed through my code and I'm sure there are no other locations where I'm setting anything else to myGlobalTintColor. It's worth noting that this UITableViewController is instantiated from a storyboard. Commenting out the line in AppDelegate.m just sends everything back to the default blue tintColor, but I still don't get the red color on the delete button.

Xander Dunn

It turns out the problem was that I was using a third party library, SDCAlertView, and I was setting

[[SDCAlertView appearance] setTintColor:globalTintColor];

For some reason, this caused all of my UINavigationBar objects to take on it's tintColor.

I fixed this by simply replacing the above code:

[[SDCAlertView appearance] setButtonTextColor:globalTintColor];

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Changing the Tint Color of UIBarButtonItem

From Java

NavigationBar bar, tint, and title text color in iOS 8

From Dev

UIBarButtonItem tint color not same color on device

From Dev

Possible to use tint color for a customview based UIBarButtonItem?

From Java

Removing the title text of an iOS UIBarButtonItem

From Dev

set tint color of an UIBarButtonItem for a specific view controller ios6

From Dev

Change default global tint color in swift

From Dev

Using global Tint color as UINavigationBars backgroundColor

From Dev

Detail Disclosure Button Color Global Tint

From Java

Change global tint color - iOS7/iOS8

From Dev

How can I change the global tint color programmatically?

From Dev

setting the text color of UIBarButtonItem by appearance proxy

From Dev

disable tint on custom uibarbuttonitem images

From Dev

How to Set tint color of text only of selected segment using Swift?

From Dev

How to set AppCompatRadioButton with text on top and change the tint color programatically?

From Dev

Global "Text" color and "TextInput" text color

From Dev

Change title text color in PreferenceActivity

From Dev

Android PreferenceFragment title text color

From Dev

SwiftUI 2 / WatchOS7 - Changing NavigationBar button & text color (was tint color now accent color)

From Dev

How to assign window tint color to view background color or lable text color dynamically- iOS

From Dev

How can I set the nav title's tint color for a modal interface in WatchKit?

From Dev

How can I tint a specific UIBarButtonItem?

From Java

Color Tint UIButton Image

From Java

Using Tint color on UIImageView

From Dev

Tint color of UIImage in XIB

From Dev

UIImage animationImages tint color?

From Dev

Individual UITabBaritem tint color

From Dev

iOS: Tabbar Tint Color

From Dev

Globally change UIBarButtonItem text color when selected or highlighted

Related Related

  1. 1

    Changing the Tint Color of UIBarButtonItem

  2. 2

    NavigationBar bar, tint, and title text color in iOS 8

  3. 3

    UIBarButtonItem tint color not same color on device

  4. 4

    Possible to use tint color for a customview based UIBarButtonItem?

  5. 5

    Removing the title text of an iOS UIBarButtonItem

  6. 6

    set tint color of an UIBarButtonItem for a specific view controller ios6

  7. 7

    Change default global tint color in swift

  8. 8

    Using global Tint color as UINavigationBars backgroundColor

  9. 9

    Detail Disclosure Button Color Global Tint

  10. 10

    Change global tint color - iOS7/iOS8

  11. 11

    How can I change the global tint color programmatically?

  12. 12

    setting the text color of UIBarButtonItem by appearance proxy

  13. 13

    disable tint on custom uibarbuttonitem images

  14. 14

    How to Set tint color of text only of selected segment using Swift?

  15. 15

    How to set AppCompatRadioButton with text on top and change the tint color programatically?

  16. 16

    Global "Text" color and "TextInput" text color

  17. 17

    Change title text color in PreferenceActivity

  18. 18

    Android PreferenceFragment title text color

  19. 19

    SwiftUI 2 / WatchOS7 - Changing NavigationBar button & text color (was tint color now accent color)

  20. 20

    How to assign window tint color to view background color or lable text color dynamically- iOS

  21. 21

    How can I set the nav title's tint color for a modal interface in WatchKit?

  22. 22

    How can I tint a specific UIBarButtonItem?

  23. 23

    Color Tint UIButton Image

  24. 24

    Using Tint color on UIImageView

  25. 25

    Tint color of UIImage in XIB

  26. 26

    UIImage animationImages tint color?

  27. 27

    Individual UITabBaritem tint color

  28. 28

    iOS: Tabbar Tint Color

  29. 29

    Globally change UIBarButtonItem text color when selected or highlighted

HotTag

Archive