美文网首页程序员iOS Developer
关于iOS开发中UINavigationController的常

关于iOS开发中UINavigationController的常

作者: KennyHito | 来源:发表于2016-12-21 16:51 被阅读30次
个人链接
微信公众号.jpg
  • 敬请关注,新功能将持续更新...
问题1:导航栏隐藏和显示
#pragma mark -- 将导航栏隐藏
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];//隐藏导航栏
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];//去除黑线
}
#pragma mark -- 将导航栏归还原样
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];//显示导航栏
    [self.navigationController.navigationBar setShadowImage:nil];//加上黑线 
}
问题2:统一设置导航栏颜色和导航栏字体的颜色
//统一设置导航栏样式,文字颜色及其大小
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlack];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance]setTitleTextAttributes:@{NSFontAttributeName:[UIFontsystemFontOfSize:17]}];
[[UINavigationBarappearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColorwhiteColor],NSFontAttributeName:[UIFontboldSystemFontOfSize:20]}];
问题3:关于iOS自定义返回按钮右滑返回手势失效的解决
self.navigationController.interactivePopGestureRecognizer.delegate=(id)self;
时间: 2016.12.21 16:51
声明
  • 所有文章出自 Kenny Hito 的博客 !
  • 未经本人允许不得转载, 转载请标明来源与作者, 谢谢合作!

相关文章

网友评论

    本文标题:关于iOS开发中UINavigationController的常

    本文链接:https://www.haomeiwen.com/subject/chbqvttx.html