关于UITabBarController的设置(iOS 开发)

1.设置图片(选中以及未选中)

UITabBarItem *TuiJianItem=[[UITabBarItem alloc]initWithTitle:@"我的" image:[[UIImage imageNamed:@"index_bottom07_"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"index_bottom08_"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];

 2.设置选中状态字体颜色

    [tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:

                                        [UIFont fontWithName:@"Helvetica-Bold" size:10],

                                        NSFontAttributeName,[UIColor colorWithRed:153/255.0 green:153/255.0 blue:153/255.0 alpha:1],NSForegroundColorAttributeName,

                                        nil] forState:UIControlStateNormal];

3.常规设置

    UITabBarController *tabBar=[[UITabBarController alloc]init];

    tabBar.viewControllers=@[_homeNav,_erShouNav,_orderNav,_tuiJianNav];

    tabBar.view.backgroundColor = [UIColor whiteColor];

    tabBar.selectedIndex = 0;//默认展示页

    tabBar.delegate=self;

 

posted @ 2017-08-21 15:00  日月哥哥  阅读(175)  评论(0编辑  收藏  举报