Skip to content

Instantly share code, notes, and snippets.

@vienvu89
Last active February 3, 2016 10:18
Show Gist options
  • Save vienvu89/cfd0c550a44873ca24f9 to your computer and use it in GitHub Desktop.
Save vienvu89/cfd0c550a44873ca24f9 to your computer and use it in GitHub Desktop.
Set Background for Tabbar Item Active and change color certain item:
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