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;//隱藏狀態欄? 最上面的電池信號欄
}