#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 = [[UIImageimageNamed:@"icon_cinema@2x"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem * item1 = [[UITabBarItem alloc]initWithTitle:@"Cinema" image:imgForItem1selectedImage:imgForItem2];
UITabBarItem * item2 = [[UITabBarItem alloc]initWithTitle:@"2" image:[UIImageimageNamed:@"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 = [[UIImageimageNamed:@"start_top250"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem * item5 = [[UITabBarItem alloc]initWithTitle:@"9" image:img1ForItem5selectedImage: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