##DAY9 UITabBarController

##DAY9 UITabBarController

UIViewController的tabBarController

UIViewController的tabBarItem

#pragma mark ———————tabBarItem——————————

UIViewController的tabBarItem属性的属性:

title 设置显示的文本

badgeValue 设置显示的角标

image 设置未点击时的图片

selectedImage 设置被选中的标签栏的图片

注意:这里的图片会受tabBarItem的影响

注意:图片想正常显示,必须是png格式

#pragma mark ———————UITabBarItem——————————

三种创建:

initWithTitle:image:selectedImage:

initWithTabBarSystemItem:tag:

initWithTitle:image:tag:

#pragma mark ———————UITabBarController——————————

UITabBarController和UINavigationController一样都是继承于UIViewController

创建:

init

属性:

viewControllers 数组,设置标签视图控制器需要管理的子视图控制器

selectedIndex 设置标签栏选中的下标

delegate 代理

selectedViewController 设置标签栏选中的视图控制器

tabBar 标签栏

#pragma mark ———————tabBar——————————

tabBar的属性:

<UITabBarDelegate> delegate

items 数组

selectedItem

tintColor

barTintColor

其他见头文件

#pragma mark ——————设置全局外观——————————

//一键换肤

//设置全局外观

//[UITabBar appearance] 找到当前应用的标签栏 UITabBar

//setTintColor: 修改显示的文本的颜色

[[UITabBar appearance] setTintColor:[UIColor greenColor]];

原文地址:https://www.cnblogs.com/chongyu/p/5192436.html