UINavigationController和UITabBarController

 -(void)change
 {
secendViewController *secend=[[secendViewController alloc]init];
//[UIApplication sharedApplication].keyWindow.rootViewController=secend;
[self presentViewController:secend animated:YES completion:^{
   NSLog(@"0.0");
}];
 }
 //返回页面
 [self dismissViewControllerAnimated:YES completion:^{
   NSLog(@"1.1");
}];
 //切换样式
secendViewController *secend=[[secendViewController alloc]init];
secend.modalTransitionStyle=3;

 UINavigationController-上标栏

 @implementation AppDelegate
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ViewController1 *viewcon=[[ViewController1 alloc]init];
UINavigationController *navc=[[UINavigationController alloc]initWithRootViewController:viewcon];
self.window.rootViewController=navc;
return YES;
 }
 第一页面
 @implementation ViewController1
 - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor redColor];
self.title=@"首页";
UIBarButtonItem *button=[[UIBarButtonItem alloc]initWithTitle:@"next" style:UIBarButtonItemStylePlain target:self action:@selector(change)];
self.navigationItem.rightBarButtonItem=button;
 //设置上标栏文字前景色    self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor redColor]};
 UIBarButtonItem *button=[[UIBarButtonItem alloc]initWithTitle:@"搜索" style:1 target:self action:@selector(change)];
//设置UIBarButtonItem的前景色
button.tintColor=[UIColor redColor];
 }
 -(void)change
 {
ViewController2 *viewcon1=[[ViewController2 alloc]init];
[self.navigationController pushViewController:viewcon1 animated:YES];
 }
 第二页面
 @implementation ViewController2
 - (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor greenColor];
self.title=@"搜索";
self.navigationItem.hidesBackButton=YES;
self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"返回" style:2 target:self action:@selector(change)];
 }
 -(void)change
 {
//栈
[self.navigationController popToRootViewControllerAnimated:YES];
 }

 UITabBarController-下标栏

 #import "AppDelegate.h"
 #import "ViewController.h"
 #import "ViewController1.h"
 #import "ViewController2.h"
 @interface AppDelegate ()
 @end
 @implementation AppDelegate
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
ViewController *viewcon=[[ViewController alloc]init];
viewcon.tabBarItem.title=@"首页";
ViewController1 *viewcon1=[[ViewController1 alloc]init];
viewcon1.tabBarItem.title=@"视频";
ViewController2 *viewcon2=[[ViewController2 alloc]init];
viewcon2.tabBarItem.title=@"分享";
UITabBarController *navc=[[UITabBarController alloc]init];
[navc setViewControllers:@[viewcon,viewcon1,viewcon2]];
self.window.rootViewController=navc;
return YES;
 }
改变颜色
 [[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor greenColor],NSForegroundColorAttributeName,[UIFont systemFontOfSize:23 weight:23],NSFontAttributeName,nil] forState:UIControlStateNormal]
屏幕快照 2016-03-14 下午7.40.23.png

UINavigationController和UITabBarController_第1张图片
屏幕快照 2016-03-14 下午7.40.34.png

屏幕快照 2016-03-14 下午7.59.58.png

你可能感兴趣的:(UINavigationController和UITabBarController)