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
  • 相关阅读:
    Github markdown页面内跳转
    github gist 无法访问
    Install pyaudio on Ubuntu
    删除链表的倒数第N个节点
    电话号码的字母组合
    最长公共前缀
    盛最多水的容器
    字符串转化整数与回文数
    Z 字形变换
    LeetCode1-5题
  • 原文地址:https://www.cnblogs.com/lidongq/p/4563606.html
Copyright © 2011-2022 走看看