如果模态出navigationController,navigationController的设置需要放在viewWillAppear里

-(void)viewWillAppear:(BOOL)animated
{
    [
super viewWillAppear:animated];
    [
self setnavigation];
}


presentViewController 模态出视图时,需要在viewWillAppear里设置navigationController,否则会出现先加载页面,后改变navigation属性,但是改变延迟,显示页面的时候,并不会设置后的效果


附:

#pragma mark -  设置 navigation
-( void )setnavigation
{
    [
self . navigationController . navigationBar   setBarStyle : UIBarStyleBlack ]; // 执行状态栏白色
    
    
    
self . navigationController . navigationBar . translucent  =  NO ; // 设置不半透明
    
//    UIBarButtonItem * rightBtn = [[UIBarButtonItem alloc]initWithImage:[[UIImage imageNamed:@" 个人中心 "]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(clickRightBtn:)];
    
//    self.navigationItem.rightBarButtonItem = rightBtn;
    
    
// 设置背景颜色
    
if  ( IS_IOS7 ) {
        
self . navigationController . navigationBar . barTintColor = [ UIColor   colorWithRed : 45.0 / 255.0   green : 45.0 / 255.0   blue : 45.0 / 255.0   alpha : 1 ];
        
        
self . navigationController . navigationBar . tintColor  = [ UIColor   whiteColor ];
        
        
// 设置标题字体和颜色
        
NSDictionary  *dic1 = [ NSDictionary   dictionaryWithObjectsAndKeys :[ UIColor   whiteColor ], NSForegroundColorAttributeName ,[ UIFont   fontWithName : @"TrebuchetMS-Bold"   size : 20 ], NSFontAttributeName  , nil ];
        [
self . navigationController . navigationBar   setTitleTextAttributes :dic1];
        [[
UINavigationBar   appearance ] setTitleTextAttributes :dic1];
    }
    
    
    
    
    
    
    
// 添加返回按钮
    
UIBarButtonItem  * leftBtn = [[ UIBarButtonItem   alloc ] initWithTitle : @" 取消 "   style : UIBarButtonItemStylePlain   target : self   action : @selector (doQuxiao)];
    
self . navigationItem . leftBarButtonItem  = leftBtn;
    
}


-(
void )doQuxiao
{
    [
self   dismissViewControllerAnimated : YES   completion : nil ];
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值