// // XMGNavigationViewController.m // 备课-百思不得姐 // // Created by MJ Lee on 15/6/15. // Copyright © 2015年 小码哥. All rights reserved. // #import "XMGNavigationViewController.h" @interface XMGNavigationViewController () @end @implementation XMGNavigationViewController + (void)initialize { UIImage *bg = [UIImage imageNamed:@"navigationbarBackgroundWhite4"]; UINavigationBar *bar = [UINavigationBar appearance]; // [bar setTintColor:[UIColor blackColor]]; [bar setBackgroundImage:bg forBarMetrics:UIBarMetricsDefault]; [bar setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:20]}]; } - (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { if (self.childViewControllers.count) { viewController.hidesBottomBarWhenPushed = YES; UIButton *button = [[UIButton alloc] init]; [button setImage:[UIImage imageNamed:@"navigationButtonReturn"] forState:UIControlStateNormal]; [button setImage:[UIImage imageNamed:@"navigationButtonReturnClick"] forState:UIControlStateHighlighted]; //button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; //[button setTitle:@"返回" forState:UIControlStateNormal]; [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [button setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted]; [button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside]; button.bounds = CGRectMake(0, 0, 44, 44); //button.contentEdgeInsets = UIEdgeInsetsMake(0, -5, 0, 0); button.titleLabel.font = [UIFont systemFontOfSize:15]; viewController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; } [super pushViewController:viewController animated:animated]; } - (void)back { [self popViewControllerAnimated:YES]; } @end