143 lines
3.5 KiB
Objective-C
143 lines
3.5 KiB
Objective-C
//
|
|
// WhiteNavBaseViewController.m
|
|
// Ifish
|
|
//
|
|
// Created by imac on 17/2/10.
|
|
// Copyright © 2017年 lianlian. All rights reserved.
|
|
//
|
|
|
|
#import "WhiteNavBaseViewController.h"
|
|
#import "UINavigationBar+Background.h"
|
|
@interface WhiteNavBaseViewController ()
|
|
|
|
@end
|
|
|
|
@implementation WhiteNavBaseViewController
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
self.view.backgroundColor = [UIColor whiteColor];
|
|
self.edgesForExtendedLayout=UIRectEdgeNone;
|
|
[self initNav];
|
|
|
|
// Do any additional setup after loading the view.
|
|
}
|
|
|
|
-(void)viewWillAppear:(BOOL)animated{
|
|
[super viewWillAppear:animated];
|
|
[self.navigationController.navigationBar setWhiteNav];
|
|
}
|
|
|
|
-(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 blackColor];
|
|
labe.font = [UIFont systemFontOfSize:19];
|
|
self.navigationItem.titleView=labe;
|
|
}
|
|
|
|
-(void)initNav{
|
|
_back =[[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"back_btn_1"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStyleDone target:self action:@selector(goBackAction)];
|
|
self.navigationItem.leftBarButtonItem=_back;
|
|
}
|
|
|
|
-(void)goBackAction{
|
|
|
|
[self.navigationController popViewControllerAnimated:YES];
|
|
}
|
|
|
|
- (void)didReceiveMemoryWarning {
|
|
[super didReceiveMemoryWarning];
|
|
// Dispose of any resources that can be recreated.
|
|
}
|
|
|
|
/*
|
|
#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.
|
|
}
|
|
*/
|
|
#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)
|
|
{
|
|
|
|
|
|
}
|
|
}
|
|
|
|
@end
|