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;

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

  • 相关阅读:
    php编译错误:jpeglib.h not found.
    php编译错误:Please reinstall the libcurl distribution
    php编译错误:Cannot find OpenSSL's <evp.h>
    php shmop windows 信号量锁
    vsftpd配置
    putty ssh 证书登录及问题
    mysql被收购 用mariadb
    centos 7 php7 yum源
    3dmax 欢迎页卡住
    用python进行服务器的监控
  • 原文地址:https://www.cnblogs.com/ErosLii/p/4479879.html
Copyright © 2011-2022 走看看