zoukankan      html  css  js  c++  java
  • 0129——UINavigationController

    1.创建一个UINavigationController

        self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];   

        FirstViewController * first = [[FirstViewController alloc]init];    

        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:first];  UINavigationController第一个显示的界面

        self.window.rootViewController = nav;

        [self.window makeKeyAndVisible];

    2.隐藏导航栏工具栏

        self.navigationController.navigationBarHidden = YES;

        self.navigationController.toolbarHidden = NO;

    3.设置导航栏和工具栏的颜色(设置了之后所有都是这个颜色,因为只有一个navigationController)

        self.navigationController.toolbar.barTintColor = [UIColor redColor];

        self.navigationController.navigationBar.barTintColor = [UIColor redColor];

    4.设置左右显示的按钮

        UIBarButtonItem * leftBtn = [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleDone target:nil action:nil];

        self.navigationItem.leftBarButtonItem = leftBtn;

        self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];

        

        UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc]initWithTitle:@"Next" style:UIBarButtonItemStyleDone target:self action:@selector(gotoSecondView)];

        self.navigationItem.rightBarButtonItem = rightBtn;

        self.navigationItem.rightBarButtonItem.tintColor = [UIColor whiteColor];

    5.设置标题

        self.navigationItem.title =@"标题";

    6.标题位置设置成view

        UIView * view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 44)];

        view.backgroundColor = [UIColor yellowColor];

        self.navigationItem.titleView = view;

    7.Next按钮响应第二个界面

    -(void)gotoSecondView{

        SecondViewController * svc = [[SecondViewController alloc]init];

        //设置默认提供的返回按钮的标题

        UIBarButtonItem *backItem = [[UIBarButtonItem allocinitWithTitle:@"返回" style:UIBarButtonItemStyleDone target:nil action:nil];

        self.navigationItem.backBarButtonItem = backItem;

        //present:在现有的界面上盖上一层 dismissViewController来消除

        //[self.navigationController presentViewController:svc animated:YES completion:nil];

        //push:push入栈 pop出栈来消除

        [self.navigationController pushViewController:svc animated:YES];

    }

  • 相关阅读:
    Qt编写安防视频监控系统27-GPU显示
    Qt开源作品37-网络中转服务器
    【日拱一卒】链表——回文判断
    【日拱一卒】链表——判断链表是否有环
    【日拱一卒】链表——链表反转(递归解法)
    批处理文件bat设置环境变量path
    用来进行序列化和反序列化的工具类
    @JsonIgnoreProperties转换实体时忽略json中不存在的字段
    如何获取mac的ip地址
    objectMapper.convertValue
  • 原文地址:https://www.cnblogs.com/damonWq/p/5168993.html
Copyright © 2011-2022 走看看