#import "ViewController.h"
@interface
ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super
viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//
设置屏幕背景色
self.view.backgroundColor = [UIColor
lightTextColor];
//
初始化UITabBar
UITabBar * tabBar = [[UITabBar
alloc]initWithFrame:CGRectMake(0,
self.view.frame.size.height -
49,
self.view.frame.size.width,
49)];
//
初始化barItem
UIImage * imgForItem1 = [UIImage
imageNamed:@"icon_cinema"];
UIImage * imgForItem2 = [[UIImage
imageNamed:@"[email protected]"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem * item1 = [[UITabBarItem
alloc]initWithTitle:@"Cinema"
image:imgForItem1
selectedImage:imgForItem2];
UITabBarItem * item2 = [[UITabBarItem
alloc]initWithTitle:@"2"
image:[UIImage
imageNamed:@"more_select_setting"]
tag:101];
UITabBarItem * item3 = [[UITabBarItem
alloc]initWithTitle:@"3"
image:[UIImage
imageNamed:@"movie_cinema"]
tag:102];
UITabBarItem * item4 = [[UITabBarItem
alloc]initWithTitle:@"Movie"
image:[UIImage
imageNamed:@"msg_new"]
tag:103];
UIImage * img1ForItem5 = [UIImage
imageNamed:@"start_top250"];
UIImage * img2ForItem5 = [[UIImage
imageNamed:@"start_top250"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem * item5 = [[UITabBarItem
alloc]initWithTitle:@"9"
image:img1ForItem5
selectedImage:img2ForItem5];
// NSBackgroundColorAttributeName
//
用字典设置item5的字体颜色
NSDictionary * dict =
@{NSFontAttributeName:[UIFont
systemFontOfSize:18],NSForegroundColorAttributeName:[UIColor
yellowColor]};
// 设置高亮状态的字体及颜色
[item5 setTitleTextAttributes:dict
forState:UIControlStateHighlighted];
NSArray * array =
@[item1,item2,item3,item4,item5];
tabBar.items = array;
[self.view
addSubview:tabBar];
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)UITabBar,UITabBarItem怎么用字典设置UITabBarItem字体大小和颜色,保持原图颜色(item5)