• 设置导航栏主题+iOS6 & iOS7 适配


     1 /**
     2  *  设置导航栏按钮主题
     3  */
     4 + (void)setupBarButtonItemTheme
     5 {
     6     UIBarButtonItem *item = [UIBarButtonItem appearance];
     7     
     8     // 设置背景
     9     if (!iOS7) {
    10         [item setBackgroundImage:[UIImage imageWithName:@"navigationbar_button_background"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    11         [item setBackgroundImage:[UIImage imageWithName:@"navigationbar_button_background_pushed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
    12         [item setBackgroundImage:[UIImage imageWithName:@"navigationbar_button_background_disable"] forState:UIControlStateDisabled barMetrics:UIBarMetricsDefault];
    13     }
    14     
    15     // 设置文字属性
    16     NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    17     textAttrs[UITextAttributeTextColor] = iOS7 ? [UIColor orangeColor] : [UIColor grayColor];
    18     textAttrs[UITextAttributeTextShadowOffset] = [NSValue valueWithUIOffset:UIOffsetZero];
    19     textAttrs[UITextAttributeFont] = [UIFont systemFontOfSize:iOS7 ? 14 : 12];
    20     [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    21     [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
    22 }
    23 
    24 /**
    25  *  设置导航栏主题
    26  */
    27 + (void)setupNavBarTheme
    28 {
    29     // 取出appearance对象
    30     UINavigationBar *navBar = [UINavigationBar appearance];
    31     
    32     // 设置背景
    33     if (!iOS7) {
    34         [navBar setBackgroundImage:[UIImage imageWithName:@"navigationbar_background"] forBarMetrics:UIBarMetricsDefault];
    35         [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
    36     }
    37     
    38     // 设置标题属性
    39     NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    40     textAttrs[UITextAttributeTextColor] = [UIColor blackColor];
    41     textAttrs[UITextAttributeTextShadowOffset] = [NSValue valueWithUIOffset:UIOffsetZero];
    42     textAttrs[UITextAttributeFont] = [UIFont boldSystemFontOfSize:19];
    43     [navBar setTitleTextAttributes:textAttrs];
    44 }
  • 相关阅读:
    关于 Kubernetes 中的 Volume 与 GlusterFS 分布式存储
    使用 Kubeadm 升级 Kubernetes 版本
    Kubernetes 中的核心组件与基本对象概述
    使用 Kubeadm 安装部署 Kubernetes 1.12.1 集群
    比较 Spring AOP 与 AspectJ
    关于 Spring Security OAuth2 中 CORS 跨域问题
    Prometheus 入门与实践
    MySQL 分支的选择:Percona 还是 MariaDB
    Spring Boot 集成 Swagger2 与配置 OAuth2.0 授权
    关于 Spring Security 5 默认使用 Password Hash 算法
  • 原文地址:https://www.cnblogs.com/qq449832375/p/4678775.html
Copyright © 2020-2023  润新知