UINavigationController-------------------------------------------
self.title = @"";//设置导航栏显示标题
self.navigationController.navigationBarHidden = yes;//隐藏导航栏
[self.navigationController.navigationBar setBackIndicatorImage:[uiimage image named:@""]]//添加图片
[image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];渲染图片
UIBarButtonItem *bar = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];//添加图标
UIBarButtonItem *bar1 = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:nil];
bar.tintColor = [UIColor yellowColor];
self.navigationItem.leftBarButtonItems = @[bar,bar1];//图标在左边
UIBarButtonItem *bar2 = [[UIBarButtonItem alloc]initWithTitle:@"das" style:UIBarButtonItemStylePlain target:self action:@selector(barPressed)];
标签栏-------------------------------------------------UITabBarController
UITabBarController *tabBarController = [[UITabBarController alloc]init];
// tabBarController.tabBar.barTintColor = [UIColor blackColor];//能设置工具栏颜色
tabBarController.tabBar.tintColor = [UIColor redColor];//图标颜色
self.window.rootViewController = tabBarController;
//有时候添加图片关闭渲染能够显示图标
UIImage *image1 = [[UIImage imageNamed:@"3"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *image2 = [[UIImage imageNamed:@"4"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
// 图标加图片 两种状态下显示
homeVc.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"home" image:image1 selectedImage:image2];
tabBarController.viewControllers =@“”;//工具栏数组,按顺序排序
// 设置代理
self.tabBarController.delegate =self;<UITabBarControllerDelegate>
//协议的方法,计算点击次数,超过10次,重新开始
static int number = 0;
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
if (tabBarController.selectedIndex == 1) {
++number;
if (number > 10) {
viewController.tabBarItem.badgeValue =nil;
number = 0;
}else{
viewController.tabBarItem.badgeValue = [NSString stringWithFormat:@"%d",number];
}
}
}
//隐藏状态栏 最上面的电池信号栏
- (BOOL)prefersStatusBarHidden{
return YES;//隐藏状态栏 最上面的电池信号栏
}