像这种效果,网上有的例子是新建一个uiview设置好大小改好颜色然后addsubview,要么就是说要用自定义.. 试了N种还是解决不了!! 其实很简单,请看:
设置tabBar背景颜色
//swift
UITabBar.appearance().backgroundColor=UIColor(red: 76/255, green:76/255, blue:76/255, alpha:1)
UITabBar.appearance().backgroundImage=UIImage()
//oc
[[UITabBarappearance]setBackgroundImage:[[UIImagealloc]init]];
[[UITabBarappearance]setBackgroundColor:[UIColorwhiteColor]];
//swift
UITabBar.appearance().backgroundColor=UIColor(red:76/255, green:76/255, blue:76/255, alpha:1)
UITabBar.appearance().backgroundImage=UIImage()
//oc
[[UITabBarappearance]setBackgroundImage:[[UIImagealloc]init]];
[[UITabBarappearance]setBackgroundColor:[UIColorwhiteColor]];
设置选中颜色
UITabBar.appearance().tintColor=UIColor.greenColor()
图片转载自CYLTabBarControllerIOS开发 经常会用到这种框架, 上边是Navigation, 下边是tabBar,又tabBar管理4个NavigationController,每个NavigationController又包含一个Controller去管理页面.
先说说思路,心急看颜色和坑的请快进到下边.
1.先建Controller然后每一个分别设为每个NavigationController的rootViewController.
2. 然后tabBarController有一个属性叫: viewControllers是个数组类型, 把navigation们都扔给他.
3. 创建好tabBarItem,别忘了xxNav.tabBarItem= xxItem或者xxController.tabBarItem= xxItem
思路大概是这样,具体可以看看CYLTabBarController的实现.
网友评论