我对 iOS 开发相当陌生,并且最近几天一直在为创建具有自定义色调的半透明导航栏而烦恼。
我现在的状态:
[[UINavigationBar appearance] setBarTintColor: [UIColor whiteColor]];
[[UINavigationBar appearance] setBarTintColor: [[UIColor whiteColor] colorWithAlphaComponent: 0.5]];
关于如何解决这个问题的任何建议?
谢谢。
最佳答案
如果您只希望导航栏的背景是半透明的,您可以尝试:
[(UIView*)[self.navigationController.navigationBar.subviews objectAtIndex:0] setAlpha:0.5f];
我在这里找到了这个:https://stackoverflow.com/a/12389579/3626094
否则,如果您希望整个导航栏是半透明的,包括按钮和标题,您可以尝试:
self.navigationController.navigationBar.tintColor = [UIColor blueColor];
self.navigationController.navigationBar.alpha = 0.5f;
self.navigationController.navigationBar.translucent = YES;
我在这里找到了这个:https://stackoverflow.com/a/6959527/3626094
关于当我设置 BarTintColor 时,iOS 导航栏失去透明度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28875932/