self.navigationbar的设置总汇
发布日期:2021-06-24 06:57:17 浏览次数:4 分类:技术文章

本文共 1774 字,大约阅读时间需要 5 分钟。

//隐藏与显示

self.navigationController.navigationBar.hidden = YES;

self.navigationController.navigationBarHidden = YES;//这个设置没有侧滑的动画

 

//navigationBar的透明问题

[self.navigationController.navigationBar setBackgroundImage:[UIImage new]

forBarMetrics:UIBarMetricsDefault];//给navigationBar设置一个空的背景图片即可实现透明,而且标题按钮都在

self.navigationController.navigationBar.shadowImage = [UIImage new];

//其实这个线也是image控制的。设为空即可

//navigationBar是一个复合视图,它是有许多个控件组成的,那么我们就可以从他的内部入手

[[self.navigationController.navigationBar subviews] objectAtIndex:0].alpha = 0;//这里可以根据scrollView的偏移量来设置alpha就实现了渐变透明的效果

//3、全局设置navigationBar标题的样式和barItem的标题样式

//UIColorWithHexRGB( )这个方法是自己定义的,这里只需要给个颜色就好了

[[UINavigationBar appearance] setBarTintColor:UIColorWithHexRGB(0xfefefe)];

[[UINavigationBar appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:18],NSForegroundColorAttributeName:UIColorWithHexRGB(0xfe6d27)}];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:10],NSForegroundColorAttributeName : UIColorWithHexRGB(0x666666)} forState:UIControlStateNormal];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSiz

//5、侧滑手势返回

if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {

//需要遵循一下手势的代理 self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.navigationController.interactivePopGestureRecognizer.enabled = YES;

//问题:当返回navigationController的最顶层的Controller的时候。再次侧滑,这个时候你在点击一个push页面的操作,你会发现卡那了,半天才会有反应。

这是由于,在最顶层Controller手势依然有效,但是滑动后,并找不到返回的页面。造成软件卡顿,假死所以就要在rootViewController中让此手势失效。把下面的设为NO

self.navigationController.interactivePopGestureRecognizer.enabled = YES;

}

 

转载于:https://www.cnblogs.com/lsh1234/p/7449198.html

转载地址:https://blog.csdn.net/weixin_30896763/article/details/98593336 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:Oracle数据库的监听配置----ORA-12514: TNS: 监听程序当前无法识别连接描述符中请求的服务解决...
下一篇:python 内置函数 map filter reduce lambda

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月13日 10时06分22秒