zoukankan      html  css  js  c++  java
  • UINavigationController 详解

    // 导航控制器

        // 1. 比较常用的视图控制器管理类

        // 2. 以栈的形式管理视图控制器, 先进后出

        // 3. 创建navigation后, 视图控制器上会多出一个导航栏

        // 4. 导航栏高度 44 + 加 状态栏 20

    对导航视图控制器的一些属性和方法的应用:

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        // 设置navigationbar 的属性
        // 1. title 标题
        self.title = @"标题";  // 这里的title被冲掉了
        self.navigationItem.title = @"XXX";
        // 2. titleview 标题视图
        // 标题视图, 修改x, y对视图本身没有影响
        UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@"晃晃", @"马峰"]];
        seg.frame = CGRectMake(0, 0, 250, 44);
        self.navigationItem.titleView = seg;
        // 3. leftBarButtonItem
        self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(back:)];
        // 4. rightBarButtonItem
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(nibBundle)];
        self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemPlay target:self action:@selector(nibBundle)];
        // 5. leftBarButtonItems
        UIBarButtonItem *barButtonItemTitle = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(back:)];
        UIBarButtonItem *barButtonItemTitle1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self action:@selector(back:)];
        self.navigationItem.leftBarButtonItems = @[barButtonItemTitle, barButtonItemTitle1];
        // 6. leftBarButtonItems
        // leftBarButtonItems 数组中放一到两个为优
        // 7. 隐藏 下面两个等效
        self.navigationController.navigationBarHidden = NO;
        self.navigationController.navigationBar.hidden = NO;
        // 8. barStyle 背景样式, 默认default
        self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
        // 9. navigationBar的背景颜色
        self.navigationController.navigationBar.backgroundColor = [UIColor redColor];
        // 10. barTintColor Bar的颜色
        self.navigationController.navigationBar.barTintColor = [UIColor redColor];
        // 11. Bar上元素的颜色
        self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
        // 12. translucent 管理半透明效果, YES为开启, NO为关闭
        UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
        button.backgroundColor = [UIColor yellowColor];
        [button addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
        button.frame = CGRectMake(0, 0, 200, 200);
        [self.view addSubview:button];
        // 设置为yes时, self.view坐标系从原点开始
        // 设置为no时, self.view坐标系从navigationBar开始
        // 默认为yes
        self.navigationController.navigationBar.translucent = YES;
        // 13. 改变坐标效果, 与translucent为NO效果一样
        //self.edgesForExtendedLayout = UIRectEdgeNone;
        // 页面跳转相关
        // 1. push 入栈 pushViewController
        // 2. pop 出栈 popViewControllerAnimated
        // 3. viewcontroller 存放navigationgController里所有的视图控制器
        // 4. topViewController 栈顶视图控制器
        // 5. visibleViewController 当前显示的视图控制器
    }
  • 相关阅读:
    无语的Filezilla
    服务无法启动集中帖
    FileZilla Server-Can’t access file错误解决方法
    CCNA2.0笔记_OSPF v3
    CCNA2.0笔记_OSPF v2
    <转>32位移植到64位 注意事项
    异步设备IO 《windows核心编程》第10章学习
    关于自己五年来做出的选择分析
    2015过年之前计划
    关于同一线程两次调用EnterCriticalSection的测试
  • 原文地址:https://www.cnblogs.com/mafeng/p/5698803.html
Copyright © 2011-2022 走看看