如何在iOS 11中将导航栏设置为透明11
问题描述:
如何将导航栏设置为透明并在iOS 11中从普通透明到透明平滑过渡?如何在iOS 11中将导航栏设置为透明11
在iOS 11之前,我找到了_UIBarBackground
视图并将其设置为alpha
在viewWillAppear:
,并且在弹出,推送和向后滑动时它工作正常。
但是在iOS 11中,_UIBarBackground
的alpha将自动在viewDidAppear
后设置为1。
所以我很好奇,有没有其他完美的解决方案?
答
设置“为下视图控制器顶棒”在情节串连图板,这样你的视图将是下导航栏
到视图添加子视图与帧{0,0,屏幕宽度,64},或使用自动布局约束。这种观点的
设置背景色:
导航栏的设置背景透明:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new]
forBarMetrics:UIBarMetricsDefault];
self.navigationController.navigationBar.shadowImage = [UIImage new];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.view.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
}
现在你可以改变yelow以透明动画
你试过'uicolor.clearcolor'吗? –