zoukankan      html  css  js  c++  java
  • iOS学习之导航条NavigationControl的一些属性设置

    /**
     *  配置公共的属性,该属性作用于所有的导航条界面;
     */
    - (void)configureConmmonPropety {
        //1.设置导航条的颜色
        self.navigationController.navigationBar.barTintColor = [UIColor yellowColor];
        //2.关闭导航条的毛玻璃效果.
        self.navigationController.navigationBar.translucent = NO;
        //3.隐藏导航条
        self.navigationController.navigationBar.hidden = NO;
        //4.设置导航条内容的渲染颜色
        self.navigationController.navigationBar.tintColor = [UIColor purpleColor];
        
        //5.设置导航条的背景图片.
        //图片尺寸不一样,显示的效果是不同的;(一定要非常严格)
    //    [self.navigationController.navigationBar setBackgroundImage:<#(UIImage *)#> forBarMetrics:<#(UIBarMetrics)#>];
        
        //6.设置导航条标题文字的大小和颜色
        NSDictionary *dic = @{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],
                              NSForegroundColorAttributeName:[UIColor redColor]
                              };
        self.navigationController.navigationBar.titleTextAttributes = dic;
     
    }
    
    
    
    /**
     *  针对当前一个界面单独定制导航条内容
     */
    - (void)customizedNavigationBarContent {
        //配置导航条上显示的标题
        self.navigationItem.title = @"第一个界面";
        //配置导航条的标题视图
        UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:@[@"国家", @"地区"]];
        self.navigationItem.titleView = segment;
        [segment release];
        //配置左边内容,显示废纸篓按钮
        UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(handleTrash:)];
        self.navigationItem.leftBarButtonItem = leftItem;
        [leftItem release];
        //配置右边内容
        UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(handleAdd:)];
        self.navigationItem.rightBarButtonItem = rightItem;
        [rightItem release];
        
    }

    //在对navigationBar进行设置时,比如添加一个scrollView,系统会自动将ScrollView下移偏离TOP 64个像素点,为了避免这样,我们有两种方法:

    1.将navigationBar的毛玻璃效果关闭;

    2.将navigationBar的属性automaticallyAdjustsScrollViewInsets = NO;

    <后续补充,今天只学了个皮毛>.

  • 相关阅读:
    @property @synthesize的含义以及误区。
    OC中类的扩展介绍
    Thinking in Java第三、四章学习笔记----操作符与控制执行流程
    LeetCode之Easy篇 ——(12)Integer to Roman
    LeetCode之Easy篇 ——(9)Palindrome Number
    LeetCode之Easy篇 ——(7)Reverse Integer
    LeetCode之Easy篇 ——(1)Two Sum
    Java关键字汇总
    Thinking in Java 第二章学习笔记----一切都是对象
    php文件上传原理详解
  • 原文地址:https://www.cnblogs.com/ErosLii/p/4479879.html
Copyright © 2011-2022 走看看