• 全局定义UINavigationContoller--By秀清


    //
    //  NavController.m
    //
    //  Created by Joe Zhang on 15/5/23.
    //  Copyright (c) 2015年 张秀清. All rights reserved.
    //
    
    #import "NavController.h"
    #import "UIBarButtonItem+Joe.h"
    #import "Prefix.h"
    
    @interface NavController ()
    
    @end
    
    @implementation NavController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        
        [self setUINavigationBar];
        
        [self setUIBarBuutonItem];
    }
    
    -(void)setUINavigationBar{
        
        if (!iOS7) {
            //Appearance  全局设置UINavigationBar
            UINavigationBar *bar = [UINavigationBar appearance];
            [bar setBackgroundImage:[UIImage imageNamed:@"navigationbar_background"] forBarMetrics:UIBarMetricsDefault];
        }
    }
    
    -(void)setUIBarBuutonItem{
        //全局设置UIBarButtonItem
        UIBarButtonItem *item = [UIBarButtonItem appearance];
        
        NSShadow *shadow = [[NSShadow alloc]init];
        shadow.shadowOffset = CGSizeMake(0, 0);
        [item setTitleTextAttributes:@{
                                       NSFontAttributeName : [UIFont systemFontOfSize:15],
                                       NSForegroundColorAttributeName : [UIColor orangeColor],
                                       NSShadowAttributeName : shadow
                                       
                                       } forState:UIControlStateNormal];
    }
    //重写Push方法
    -(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
        
        
        if (self.viewControllers.count>0) {//如果栈底的控制器个数大于0(tabbar4个nav之后的控制器)
            
            viewController.hidesBottomBarWhenPushed = YES;//隐藏底部tabbar
           
            viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_back" highLightImageName:@"navigationbar_back_highlighted" target:self action:@selector(back)];
            
            viewController.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithImageName:@"navigationbar_more" highLightImageName:@"navigationbar_more_highlighted" target:self action:@selector(pop)];
            
        }
        [super pushViewController:viewController animated:YES];
    }
    
    -(void)back{
        
        [self popViewControllerAnimated:YES];
    }
    
    -(void)pop{
        
        [self popToRootViewControllerAnimated:YES];
    }
    
    @end
  • 相关阅读:
    Overload和Override的区别。Overloaded的方法是否可以改变返回值的类型?
    "=="和equals方法究竟有什么区别?
    Tomcat发生java.lang.OutOfMemoryError: PermGen space的解决方案
    HashMap原理
    springMVC
    SqlServer和Oracle修改表结构语句
    quartz定时任务时间表达式说明
    Linq to Entity 时间差作为筛选条件产生的问题
    密码学基础
    C#如何使用异步编程【BeginInvoke/EndInvoke】
  • 原文地址:https://www.cnblogs.com/sixindev/p/4525891.html
Copyright © 2020-2023  润新知