简体   繁体   中英

Can't change tabbar tintColor with a custom color

i'm trying to change the color of the tabbar with a custom color but seems that there is no way to do it ...

I have defined a category for the UIColor class in this way :

@implementation UIColor (UakariColor)

+(UIColor *) defaultUakariColor {
    return [UIColor colorWithRed:237.0/255.0 green:28.0/255.0 blue:36.0/255.0 alpha:0];
}
@end

I then i'm trying to set the color of the tabbar with my custom color in this way (in the custom tab bar controller) :

//Change the color of the tabbar
if([[self tabBar] respondsToSelector:@selector(setTintColor:)])
    [[self tabBar] setTintColor:[UIColor defaultUakariColor]];

but it doesn't work (the tab bar is black ), if i instead set a standard color like redcolor :

[[self tabBar] setTintColor:[UIColor redColor]];

It works, and set the color to red ...

Why with a custom color doesn't work ? Is it a BUG ?

if u have set alpha(opacity) to 0 then it will be like clear color so it as per your requirment u set it to 1 . So do this:

@implementation UIColor (UakariColor)

+(UIColor *) defaultUakariColor {
return [UIColor colorWithRed:(237.0/255.0) green:(28.0/255.0) blue:(36.0/255.0) alpha:1];
}
@end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM