您的位置:首页 > 其它

导航栏与状态栏

2015-11-04 13:55 344 查看
//1.设置状态栏的字体为白色
- (UIStatusBarStyle)preferredStatusBarStyle{

    

    [superpreferredStatusBarStyle];

    

    returnUIStatusBarStyleLightContent;
}

//2.设置s所有Push之后的界面

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated
{

    if (self.viewControllers.count
> 0) {

        
        viewController.view.backgroundColor = [UIColorcolorWithRed:.95green:.95blue:.95alpha:1.0];
        viewController.hidesBottomBarWhenPushed =YES;

        [self.navigationBarsetBackgroundImage:[UIImageimageNamed:@"daohanglan"]forBarMetrics:UIBarMetricsDefault];
    }
    [superpushViewController:viewControlleranimated:animated];
}

//3.设置导航栏的字体大小与颜色

 self.navigationController.navigationBar.titleTextAttributes
= @{
                                                                   NSForegroundColorAttributeName:[UIColorwhiteColor],
                                                                   NSFontAttributeName:[UIFontboldSystemFontOfSize:18]

                                                                    
                                                                   };

    

//4.设置文字item的文字大小
 UIBarButtonItem *rightItems = [[UIBarButtonItemalloc]initWithTitle:@"注册"style:UIBarButtonItemStylePlaintarget:selfaction:@selector(rightAction:)];

    [rightItems setTitleTextAttributes:[NSDictionarydictionaryWithObjectsAndKeys:[UIFontfontWithName:@"Helvetica-Bold"size:14.0],NSFontAttributeName,nil]forState:UIControlStateNormal];

    

    self.navigationItem.rightBarButtonItem = rightItems;

    

//5.SB设置button为圆角



//6.push过去隐藏导航栏

    playVC.hidesBottomBarWhenPushed =YES;

//7.设置返回按钮的颜色

  navBar.tintColor =UIColor.orange

设置不同控制器的状态栏颜色不同

-(void)viewWillAppear:(BOOL)animated

{

    [super
viewWillAppear:animated];

    

    //设置不同界面的状态栏颜色不同

    // 还得设置plist
里面  View controller-based status bar appearance 
设置为no

    

    [UIApplication
sharedApplication].statusBarStyle =
UIStatusBarStyleLightContent;

}

- (void)viewDidAppear:(BOOL)animated{

    [super
viewDidAppear:animated];

    [self.navigationController.navigationBar
setShadowImage:[UIImage
new]];

    [UIApplication
sharedApplication].statusBarStyle =
UIStatusBarStyleLightContent;

}

- (void)viewWillDisappear:(BOOL)animated{

    

    [super
viewWillDisappear:animated];

    [UIApplication
sharedApplication].statusBarStyle =
UIStatusBarStyleDefault;

    

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: