zoukankan      html  css  js  c++  java
  • 全局定义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
  • 相关阅读:
    将网站从WSS2.0升级到WSS3.0的心得
    Teched 2008课程:ADO.NET Data Service & UC开发概览
    我的基于Silverlight2的相册,也刚刚升级到了RTW了。
    ubuntu16.04设置python3为默认及一些库的安装
    CDMA手机的MEID
    CDMA Subscription 模式设置
    Android架构纵横谈之——软件自愈能力(转载)
    CDMA系统中的用户识别卡(UIM)和空中激活技术(OTA)
    手机信号强度全解析
    GSMPhone与CDMAPhone切换过程
  • 原文地址:https://www.cnblogs.com/sixindev/p/4525891.html
Copyright © 2011-2022 走看看