Customize UIBarButtonSystemItem Tint Color with UIAppearance API

I know that I can customize the text UIBarButtonItemthrough

setTitleTextAttributes:forState:

There is also a way to customize the icons UITabBarwith

setSelectedImageTintColor:

Is there a way to adjust the hue color UIBarButtonSystemItem(like the color of the trash can icon) just to have a consistent UX? I could not find anything.

If this is not possible, how can I continue? Should I keep the color version of the icon? Where can I find him? What would be the easiest way to change it?

EDIT

To clarify, this is not the background color UIBarButtonItemthat I ask, but the outline color of the icon.

EDIT

Setting the hue color UIBarButtonItemgives the background color of the button set.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];


    [[UINavigationBar appearance] setTintColor:[UIColor greenColor]];

    UIBarButtonItem* trashButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:nil action:nil];

    trashButton.tintColor = [UIColor blackColor];
    UIViewController* viewController = [[UIViewController alloc] init];
    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:viewController];
    [viewController.navigationItem setRightBarButtonItem:trashButton];

    self.window.rootViewController = navController;
    return YES;
}

gives this one .

EDIT 2

, tintColor UIBarButtonItem, style UIBarButtonItemStylePlain. ( . [UIColor blackColor]). , UIBarButtonItem UINavigationBar, style UIBarButtonItemStyleBordered. tintColor .

UIBarButtonItem , .

+5
3

, png ,

[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"UIButtonBarTrashBlack"] style:UIBarButtonItemStyleBordered target:self action:@selector(myAction)];

, UIKit-Artwork-Extractor.

GIMP.

+5

. , , .

tintColor UIBarButtonItem. , appearance .

, appearance. , .

Update:

UIBarButtonItem *btnAdd = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addAction)];
btnAdd.tintColor = [UIColor blackColor];

, ( , ).

+7

Instead of using black, use this:

[UIColor colorWithRed: 0 green: 0 blue: 0 alpha: 1]; // [UIColor blackColor] makes it white

-1
source

All Articles