WRNavigationBar 使用记录

最近在做一个导航栏透明度渐变的效果,发现

WRNavigationBar库很好用,一开始导入到项目,发现导航tiltle颜色一直是黑色的,无论怎么用系统方法改都改不了。后来发现原来库里面有一个方法可以设置默认颜色。

 // 下面是直接用WRNavigationBar 处理导航栏的透明度
    MainNavBarColor = [UIColor colorWithRed:0/255.0 green:175/255.0 blue:240/255.0 alpha:1];
    MainViewColor   = [UIColor colorWithRed:126/255.0 green:126/255.0 blue:126/255.0 alpha:1];
    
    // 设置导航栏默认的背景颜色
    [WRNavigationBar wr_setDefaultNavBarBarTintColor:[UIColor blackColor]];
    // 设置导航栏所有按钮的默认颜色
    [WRNavigationBar wr_setDefaultNavBarTintColor:[UIColor whiteColor]];
    // 设置导航栏标题默认颜色
    [WRNavigationBar wr_setDefaultNavBarTitleColor:[UIColor whiteColor]];
    // 统一设置状态栏样式
    [WRNavigationBar wr_setDefaultStatusBarStyle:UIStatusBarStyleLightContent];
    // 如果需要设置导航栏底部分割线隐藏,可以在这里统一设置
    [WRNavigationBar wr_setDefaultNavBarShadowImageHidden:YES];

 

 

其实如果只是想设置透明导航栏 不想下拉滑动下面的table时导航栏变化的话,这个也可以:

 

//- (void)viewWillAppear:(BOOL)animated{
//
//    //设置导航栏背景图片为一个空的image,这样就透明了
//    [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
//
//    //去掉透明后导航栏下边的黑边
//    [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
//}

//- (void)viewWillDisappear:(BOOL)animated{
//
//    //如果不想让其他页面的导航栏变为透明 需要重置
//    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
//    [self.navigationController.navigationBar setShadowImage:nil];
//}

 

posted @ 2018-05-20 09:39  liuw_flexi  阅读(2745)  评论(0编辑  收藏  举报