Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how can i change the tabbarItem's icon tintColor? #94

Open
304164084 opened this issue Nov 28, 2018 · 0 comments
Open

how can i change the tabbarItem's icon tintColor? #94

304164084 opened this issue Nov 28, 2018 · 0 comments

Comments

@304164084
Copy link

304164084 commented Nov 28, 2018

Looking forward to your reply!!!

The final result is as follows:

`- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.

self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
ViewController *vc1 = [[ViewController alloc] init];
ViewController *vc2 = [[ViewController alloc] init];
UITabBarController *tvc = [[UITabBarController alloc] init];
[tvc setViewControllers:@[vc1, vc2]];

[tvc.tabBar.items enumerateObjectsUsingBlock:^(UITabBarItem * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
    NSString *title = [NSString stringWithFormat:@"vc->%ld", idx];
    UIImage *selectedImage = [[UIImage imageNamed:@"tabbar_cate_highlight"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    UIImage *normalImage = [[UIImage imageNamed:@"tabbar_cate"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
    
    obj.title = title;
    obj.image = normalImage;
    obj.selectedImage = selectedImage;
}];

[[UITabBar appearance] setTintColor:[UIColor redColor]];
[[UITabBar appearance] setUnselectedItemTintColor:[UIColor yellowColor]];

self.window.rootViewController = tvc;

[self.window makeKeyAndVisible];
return YES;

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant