// // KDPMainViewController.m // KuDianProject // // Created by 学丽 on 2019/7/4. // Copyright © 2019 KDP. All rights reserved. // #import "KDPMainViewController.h" @interface KDPMainViewController () @end @implementation KDPMainViewController - (void)viewDidLoad { [super viewDidLoad]; [self.view addSubview:self.navBar]; } -(void)viewWillLayoutSubviews { self.view.frame=[UIScreen mainScreen].bounds; } -(void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; self.navigationController.navigationBar.hidden=YES; [self.view bringSubviewToFront:self.navBar]; } -(KDPNavBar *)navBar { if (!_navBar) { _navBar=[[KDPNavBar alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, KDNavBarHeight)]; //代码写在这个里面 @try{ _navBar.backgroundColor=[UIColor gradientOneColor:[UIColor colorWithHexString:@"#FF235F"] toColor:[UIColor colorWithHexString:@"#FF7676"] Width:SCREEN_WIDTH]; } @catch(NSException *exception) { NSLog(@"异常错误是:%@", exception); } @finally { } } return _navBar; } @end