// // ClearNavBaseViewController.m // Ifish // // Created by imac on 17/3/14. // Copyright © 2017年 lianlian. All rights reserved. // #import "ClearNavBaseViewController.h" #import "UINavigationBar+Background.h" @interface ClearNavBaseViewController () @end @implementation ClearNavBaseViewController - (void)viewDidLoad { [super viewDidLoad]; self.edgesForExtendedLayout=UIRectEdgeNone; // Do any additional setup after loading the view. self.view.backgroundColor = TABLE_BACKGROUD_COLOR; [self initNav]; } -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [self.navigationController.navigationBar setClearNav]; } -(void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; } - (void)addTitleViewWithTitle:(NSString *)title{ UILabel*labe=[[UILabel alloc]initWithFrame:CGRectMake(0, 0, 60, 44)]; labe.text=title; labe.textAlignment=NSTextAlignmentCenter; labe.textColor=[UIColor whiteColor]; labe.font = [UIFont systemFontOfSize:19]; self.navigationItem.titleView=labe; } -(void)initNav{ // 1. 可以改变全栈back按钮 图片 60*60 @2x像素 _bakbutton = [UIButton buttonWithType:UIButtonTypeCustom]; _bakbutton.frame = CGRectMake(0,0,48,44); [_bakbutton setImage:[UIImage imageNamed:@"back_btn"] forState:UIControlStateNormal]; _bakbutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; [_bakbutton setContentEdgeInsets:UIEdgeInsetsMake(0, 10, 0, -10)]; [_bakbutton addTarget: self action: @selector(goBackAction) forControlEvents: UIControlEventTouchUpInside]; _back=[[UIBarButtonItem alloc] initWithCustomView:_bakbutton]; self.navigationItem.leftBarButtonItem=_back; } -(void)goBackAction{ [self.navigationController popViewControllerAnimated:YES]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } #pragma mark - 竖屏时,显示状态栏 //白色导航黑色状态栏 -(BOOL)prefersStatusBarHidden { return NO; } - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleDefault; } #pragma mark - 屏幕Autorotate -(BOOL)shouldAutorotate{ return YES; } #pragma mark 屏幕支持的旋转方向 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interface { return (interface == UIInterfaceOrientationPortrait || interface == UIInterfaceOrientationLandscapeRight); } // #ifdef IOS6 - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { return UIInterfaceOrientationLandscapeRight; } - (BOOL)shouldAutorotate { return NO; } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight; } #endif // #pragma mark 支持哪些方向 -(UIInterfaceOrientationMask)supportedInterfaceOrientations{ return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeRight; } #pragma mark 一开始希望的屏幕方向 -(UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{ return UIInterfaceOrientationPortrait; } #pragma mark - 屏幕旋转 -(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration { if (toInterfaceOrientation == UIInterfaceOrientationPortrait) { } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) { } else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) { } } /* #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