Last active
March 19, 2018 08:13
-
-
Save lloydsheng/6459429 to your computer and use it in GitHub Desktop.
一端iOS5.0以上订制UITabbar的代码
This file contains hidden or 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
[self.tabBar setSelectionIndicatorImage:[UIImage imageNamed:@"tab-bar_highlighted.png"]]; | |
[[UITabBarItem appearance] setTitleTextAttributes: | |
[NSDictionary dictionaryWithObjectsAndKeys: | |
RGB(187, 187, 187), UITextAttributeTextColor, | |
[UIFont systemFontOfSize:10], UITextAttributeFont, | |
nil] | |
forState:UIControlStateNormal]; | |
[[UITabBarItem appearance] setTitleTextAttributes: | |
[NSDictionary dictionaryWithObjectsAndKeys: | |
RGB(153, 210, 249), UITextAttributeTextColor, | |
[UIFont systemFontOfSize:10], UITextAttributeFont, | |
nil] | |
forState:UIControlStateSelected]; | |
[self.tabBar setBackgroundImage:[UIImage imageNamed:@"tab-bar.png"]]; | |
for (NSInteger i = 0; i < self.tabBar.items.count; i++) { | |
UITabBarItem *item = [self.tabBar.items objectAtIndex:i]; | |
[item setTitle:[titles objectAtIndex:i]]; | |
item.titlePositionAdjustment = UIOffsetMake(1, -2); | |
[item setFinishedSelectedImage:[UIImage imageNamed:[selectedImageNames objectAtIndex:i]] | |
withFinishedUnselectedImage:[UIImage imageNamed:[imageNames objectAtIndex:i]] | |
]; | |
[item setImageInsets:UIEdgeInsetsMake(1 -1, 0, -1 + 1, 0)]; | |
} | |
UIImageView *view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; | |
view.backgroundColor = [UIColor redColor]; | |
[self.tabBar addSubview:view]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment