zoukankan      html  css  js  c++  java
  • 自定导航控制器

    //
    //  CustNavigationViewController.m
    //  生活荟
    //
    //  Created by 李冬强 on 15-1-19.
    //  Copyright (c) 2015年 ldq. All rights reserved.
    //
    
    #import "CustNavigationViewController.h"
    
    @interface CustNavigationViewController ()
    
    @end
    
    @implementation CustNavigationViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    }
    
    // 第一次使用这个类调用
    + (void)initialize
    {
        // 设置导航栏主题
        [self setupNavBarTheme];
        // 设置导航栏item主题
        [self setupBarButtonItemTheme];
        
    }
    
    // 设置导航栏主题
    + (void)setupNavBarTheme
    {
        // 取出 appearance对象
        UINavigationBar *navBar = [UINavigationBar appearance];
        [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];
        
        // 设置背景
    //    navBar.barTintColor = ;
        
        // 设置标题属性
        NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
        textAttrs[NSForegroundColorAttributeName] = kZhuTiColor;
        textAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:22];
        [navBar setTitleTextAttributes:textAttrs];
    }
    
    // 设置导航栏item主题
    + (void)setupBarButtonItemTheme
    {
        UIBarButtonItem *item = [UIBarButtonItem appearance];
        // 设置背景
        
        // 设置文字属性
        NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
        textAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
        textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize: 15];
        [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
        [item setTitleTextAttributes:textAttrs forState:UIControlStateHighlighted];
        NSMutableDictionary *disableTextAttrs = [NSMutableDictionary dictionary];
        disableTextAttrs[NSFontAttributeName] = [UIColor lightGrayColor];
        [item setTitleTextAttributes:disableTextAttrs forState:UIControlStateDisabled];
    }
    
    - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
    {
        if (self.viewControllers.count > 0) {
            viewController.hidesBottomBarWhenPushed = YES;
        }
        [super pushViewController:viewController animated:animated];
    }
    
    
    - (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }
    
    /*
    #pragma mark - Navigation
    
    // In a storyboard-based application, you will often want to do a little preparation before navigation
    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
        // Get the new view controller using [segue destinationViewController].
        // Pass the selected object to the new view controller.
    }
    */
    
    @end
  • 相关阅读:
    基于网络服务器端的网口测试-软件
    JAVA中操作符的优先级
    逻辑操作符、位操作符号的忽略点
    Java配置环境变量、方法和原因
    Java中常用的字符编码-解析
    SVM
    C#与matlab混合编程
    Python 3 and MySQL
    PyMySQL Evaluation
    PYTHON3连接MYSQL数据库
  • 原文地址:https://www.cnblogs.com/lidongq/p/4563606.html
Copyright © 2011-2022 走看看