Last active
February 3, 2016 10:18
-
-
Save vienvu89/cfd0c550a44873ca24f9 to your computer and use it in GitHub Desktop.
Set Background for Tabbar Item Active and change color certain item:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSInteger numberOfItems = self.tabBar.items.count; | |
CGSize tabBarItemSize = CGSizeMake(self.tabBar.frame.size.width / numberOfItems, self.tabBar.frame.size.height); | |
self.tabBar.selectionIndicatorImage = [UIImage imageWithColor:[UIColor colorWithHexString:@"#040A0F" ] size:tabBarItemSize]; | |
NSInteger itemIndex = 2; | |
CGFloat itemWidth = self.tabBar.frame.size.width / numberOfItems; | |
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(itemWidth * itemIndex, 0, itemWidth, self.tabBar.frame.size.height)]; | |
bgView.backgroundColor = [UIColor colorWithHexString:@"#BB0002"]; | |
[self.tabBar insertSubview:bgView atIndex:0]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment