CocoaPods trunk is moving to be read-only. Read more on the blog, there are 17 months to go.

TYNavigationBar 0.1.8

TYNavigationBar 0.1.8

Maintained by Yu.Tian.



  • By
  • Style-Tender

TYNavigationBar

一个导航栏管理器,每个控制器只需要关心自己的导航栏样式

使用方法

  • 拖动 TYNavigationBarManager.hTYNavigationBarManager.m到工程中
  • 在需要管理导航栏的控制器中 #import "TYNavigationBarManager.h",建议在控制器的基类中导入
  • 或者 pod 'TYNavigationBar', '~> 0.1.3'

类方法列表

  • 默认导航栏背景颜色 + (void)ty_setDefaultNavigationBarBackgroundColor:(UIColor *)color;

  • 默认状态栏Style + (void)ty_setDefaultStatusBarStyle:(UIStatusBarStyle) style;

  • 默认导航栏的Tint颜色 + (void)ty_setDefaultNavigationBarTintColor:(UIColor *)color;

  • 默认导航栏标题的字体颜色 + (void)ty_setDefaultNavigationBarTitleTextColor:(UIColor *)color;

  • 默认导航栏背景透明度 + (void)ty_setDefaultNavigationBarBackgroundAlpha:(CGFloat)alpha;

  • 默认导航栏横线的隐藏 + (void)ty_setDefaultNavigationBarShadowImageHidden:(BOOL)hidden;

对象方法列表

  • 设置导航栏背景颜色 - (void)ty_setNavigationBarBackgroundColor:(UIColor *)color;

  • 设置状态栏Style - (void)ty_setStatusBarStyle:(UIStatusBarStyle) style;

  • 设置导航栏的Tint颜色 - (void)ty_setNavigationBarTintColor:(UIColor *)color;

  • 设置导航栏标题的字体颜色 - (void)ty_setNavigationBarTitleTextColor:(UIColor *)color;

  • 设置导航栏背景透明度 - (void)ty_setNavigationBarBackgroundAlpha:(CGFloat)alpha;

  • 设置导航栏横线的隐藏 -(void)ty_setNavigationBarShadowImageHidden:(BOOL)hidden;

  • 设置导航栏隐藏 - (void)ty_setNavigationBarHidden:(BOOL)hidden;

  • 添加子控制器-使用父控制器的导航栏属性 - (void)ty_addChildViewController:(UIViewController *)viewController;

示例

在控制器

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initNav];
    
    [self initView];
}

-(void)initNav{
    [self ty_setStatusBarStyle:UIStatusBarStyleLightContent];
    
    [self ty_setNavigationBarTitleTextColor:UIColor.whiteColor];
    
    self.navigationItem.title = @"首页";
    
    [self ty_setNavigationBarBackgroundColor:UIColor.redColor];
    
    [self ty_setNavigationBarBackgroundAlpha:0.3];
    
    [self ty_setNavigationBarShadowImageHidden:NO];
}

注意

如果你的代码里用到了addChildViewController:的代码,需要替换成ty_addChildViewController:,否则父控制器的导航栏样式会被替换。目前没有找到合适的解决办法,只能先这样解决了