zoukankan      html  css  js  c++  java
  • 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 =@"标题";

        self.navigationBar.titleTextAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:16],NSForegroundColorAttributeName:[UIColor whiteColor]};

    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];

    }

  • 相关阅读:
    WPF中DataGrid的应用-绑定,增改删,分页,样式
    每隔一秒获取时间
    常识
    VS2013程序打包部署详细图解
    Vs2010 WPF 项目打包
    WPF InkCanvas 画图 基础使用教程
    WPF Template模版之寻找失落的控件【三】
    WPF Template模版之DataTemplate与ControlTemplate【一】
    WPF Template模版之DataTemplate与ControlTemplate的关系和应用【二】
    淡入效果
  • 原文地址:https://www.cnblogs.com/huoran1120/p/5168596.html
Copyright © 2011-2022 走看看