背景颜色的设置
1
2
|
NSString *tabbarBackgroundImage = [[NSBundle mainBundle] pathForResource:@ "bg_tabbar@2x" ofType:@ "png" ]; [[UITabBar appearance] setBackgroundImage:[UIImage imageWithContentsOfFile:tabbarBackgroundImage]]; |
tabbar选择后的背景设置(这里由于图片的大小,做了一下图片的大小调整)
1
2
3
4
|
UIImage *image = [UIImage imageWithContentsOfFile:tabbarBackgroundImage]; CGSize size = CGSizeMake(20.0, 0.5); UIImage *resizeImage = [self reSizeImage:image toSize:size]; [[UITabBar appearance] setSelectionIndicatorImage:resizeImage]; |
tabbar字体的颜色设置
1
|
[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor grayColor],UITextAttributeTextColor, nil] forState:UIControlStateNormal]; |
加一个图片重新调整的函数
1
2
3
4
5
6
7
8
9
10
|
- (UIImage *)reSizeImage:(UIImage *)image toSize:(CGSize)reSize { UIGraphicsBeginImageContext(CGSizeMake(reSize.width, reSize.height)); [image drawInRect:CGRectMake(0, 0, reSize.width, reSize.height)]; UIImage *reSizeImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return reSizeImage; }
|