• UINavgationViewController


     

    一.        设置全部导航条的背景

    // 取出全部导航条

    UINavigationBar *bar = [UINavigationBar appearance];    

    // 设置全部导航条的背景图片

      [bar setBackgroundImage:[UIImage imageName: @"navigationbar_background.png"] forBarMetrics:UIBarMetricsDefault];

      // 导航栏上有一层BackgroundImageView,不能直接设置背景颜色,设置背景颜色是无效的

    //    bar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navigationbar_background.png"]];

    // 设置导航栏文字的主题

     [bar setTitleTextAttributes:@{

             UITextAttributeTextColor : [UIColor darkGrayColor]                            UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero]

        }];

    二.设置导航条上所有Item

    // 设置全部item的背景

    // 取出导航条上所有item

       UIBarButtonItem *items = [UIBarButtonItem appearance];

       

        // 设置item的背景

        [items setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

        [items setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background_pushed.png"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];

     

        // 设置item的文字主题

        NSDictionary *dict = @{UITextAttributeTextColor : [UIColor darkGrayColor],

                               UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero],

                               UITextAttributeFont : [UIFont systemFontOfSize:13]

                               };

        [items setTitleTextAttributes:dict forState:UIControlStateNormal];

    [items setTitleTextAttributes:dict forState:UIControlStateHighlighted];

    三.设置状态栏模式

        // 设置状态栏,因为给导航条设置了颜色,状态栏会随着导航条的颜色改变而改变,所以我们需要设置为黑色。

    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;

    四.导航控制器不能设置左右item和中间的文字,导航控制器本身不具备显示功能,他是通过跟控制器显示的,不要傻乎乎的给导航控制器设置左右item。

    五.如果需要在跳转页面的时候,做一些操作效果,可以自定义导航控制器重写push或者pop方法(重写这个方法,也可以取消一些不想要的效果),或者作为导航控制器的代理,监听跳转方法。

    - (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated

    - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

  • 相关阅读:
    在线用户数与并发用户数的区别和比例关系
    MYSQL中数据类型介绍
    5分钟教你搞定RAID模式
    nginx与fastdfs配置详解与坑
    Fastdfs group通过添加硬盘扩容
    fastDfs配置文件tracker.conf配置详解
    FastDFS配置详解之Storage配置
    mysql修改库名
    vCenter Server Appliance(VCSA )6.7部署指南
    如何知道一个函数的执行时间简单案例
  • 原文地址:https://www.cnblogs.com/qiling/p/4894719.html
Copyright © 2020-2023  润新知