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
  • 相关阅读:
    在 Borland C++ 及 Visual C++ 环境中使用 STLport (作者:孟岩)
    设置JavaFX-CSS改变TreeView节点图标
    Using MS DataGrid control with ADO
    两个加载fxml文件的方法
    JavaFX中ObservableValue类型
    在 Eclipse 下利用 gradle 构建系统
    JavaFX初探
    深度剖析如何保证缓存与数据库的一致性
    ACID的实现原理
    一颗高度为3的B+树能存多少行数据?
  • 原文地址:https://www.cnblogs.com/lidongq/p/4563606.html
Copyright © 2011-2022 走看看