UITabBarItem *firstItem = [[UITabBarItem alloc]initWithTitle:@"测试" image:nil tag:11];
//设置字体颜色(后面设置字体状态)(UITextAttributeTextColor已过时)
[firstItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIColor grayColor], UITextAttributeTextColor, nil] forState:UIControlStateNormal];
//设置图片(选中和未选中)(此方法也已过时)
[firstItem setFinishedSelectedImage:[UIImage imageNamed:@"local"] withFinishedUnselectedImage:[UIImage imageNamed:@"localClick"]];
#import "MyTabBar.h"
@implementation MyTabBar
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
//通过三原色设置背景颜色
self.backgroundColor = [UIColor colorWithRed:86/250.0f green:140/250.0f blue:158/250.0f alpha:1];
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
}
@end