iOS中自定义导航控制器NavigationController

来源:互联网 发布:区块链 对等网络 编辑:程序博客网 时间:2024/04/30 11:12
iOS中自定义导航控制器NavigationController
#import "NavigationController.h"@interface NavigationController ()@end@implementation NavigationController- (void)viewDidLoad {    [super viewDidLoad];   }/** *  系统在第一次使用这个类的时候调用 */+(void)initialize{    //1.设置导航栏主题    UINavigationBar *navBar=[UINavigationBar appearance];            NSString *bgName=nil;        if (iOS7) {            bgName=@"NavBar64";            //箭头的颜色            navBar.tintColor=[UIColor whiteColor];            }else{        bgName=@"NavBar";        }        //设置背景图片    [navBar setBackgroundImage:[UIImage imageNamed:bgName] forBarMetrics:UIBarMetricsDefault];    //设置标题文字颜色    NSMutableDictionary *attrs=[NSMutableDictionary dictionary];    attrs[NSFontAttributeName]=[UIFont systemFontOfSize:18];    attrs[NSForegroundColorAttributeName]=[UIColor whiteColor];    [navBar setTitleTextAttributes:attrs];    //2.设置BarButtonItem的主题    UIBarButtonItem *item=[UIBarButtonItem appearance];     //设置文字颜色    NSMutableDictionary *itemAttrs=[NSMutableDictionary dictionary];    itemAttrs[NSFontAttributeName]=[UIFont systemFontOfSize:14];    itemAttrs[NSForegroundColorAttributeName]=[UIColor whiteColor];    [item setTitleTextAttributes:itemAttrs forState:UIControlStateNormal];    if (!iOS7) {        //设置导航按钮背景        [item setBackgroundImage:[UIImage imageNamed:@"NavBackButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];        [item setBackgroundImage:[UIImage imageNamed:@"NavBackButtonPressed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];                //设置返回按钮的背景        [item setBackButtonBackgroundImage:[UIImage imageNamed:@"NavBackButton"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];        [item setBackButtonBackgroundImage:[UIImage imageNamed:@"NavBackButtonPressed"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];    }}/** *  重写这个方法,能拦截所有的push操作,隐藏tabBar * */-(void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{    viewController.hidesBottomBarWhenPushed=YES;    [super pushViewController:viewController animated:animated];   }//-(UIViewController *)popViewControllerAnimated:(BOOL)animated//{//    return [super popViewControllerAnimated:NO];//}@end


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 黑衣服旧了发白怎么办 黑色衣服洗白了怎么办 黑衣服洗了泛白怎么办 刚买的衣服掉色怎么办 棉质的衣服褪色怎么办 黑裤子晒掉色了怎么办 新买的衣服褪色怎么办 衣服洗了掉毛怎么办 衣服受潮长了斑点怎么办 黑色的衣服粘毛怎么办 黑衣服容易粘毛怎么办 衣服上粘了毛毛怎么办 黑衣服防止粘毛怎么办 洗黑色衣服掉毛怎么办 兔毛的衣服掉毛怎么办 带绒的衣服掉毛怎么办 黑裤子被84掉色怎么办 买的衣服掉毛怎么办 裤子穿久了泛亮怎么办 新买的裤子褪色怎么办 黑裤子掉毛严重怎么办 黑裤子洗完发白怎么办 新买羊绒衫掉毛怎么办 皮草毛卷起来了怎么办 小孩衣服洗不干净怎么办 衣服沾上钢笔水怎么办 羊绒衫洗了掉毛怎么办 白衬衫弄上墨水怎么办 羊毛衬衫洗错了怎么办 婚纱照拍的太丑怎么办 微信加人没反应怎么办 新买的毛毯有味怎么办 科二第一次练车怎么办 毛呢大衣起球了怎么办 毛呢衣服起球了怎么办 羊毛呢外套起球怎么办 毛呢外套起球了怎么办 呢子外套起球了怎么办 子持白莲徒长后怎么办 佛珠多肉干瘪了怎么办 多肉植物长高了怎么办