注意:该文章使用UINavigationController来进行操作
如果我们不使用这些美化操作,建立出的分栏控制器是这样的:
我们修改一下title内容,加个图片,改个颜色位置
建立出的分栏控制器是这样的:
设置字体大小:
//设置title字体大小
[nav1.tabBarItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys: [UIFont systemFontOfSize:15], NSFontAttributeName, nil] forState:UIControlStateNormal];
设置位置偏移:
//设置title位置偏移
UIOffset offset1;
offset1.horizontal = 2;
offset1.vertical = 13;
[nav1.tabBarItem setTitlePositionAdjustment:offset1];
//未选中状态的图片
nav1.tabBarItem.image = [[UIImage imageNamed:@"Bean-Flap-Homeun.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//选中状态的图片
nav1.tabBarItem.selectedImage = [UIImage imageNamed:@"Bean-Flap-Home.png"];
字体颜色的设置:
tabBarController.view.tintColor = [UIColor colorWithRed:0.18 green:0.69 blue:0.33 alpha:1.0];