我已经做了很多尝试来使 UINavigationBar 透明。但是我没有这样做。我设置的图像是透明的。这是我的代码。 有什么帮助吗? 提前致谢。
[rootNavC.navigationBar setBackgroundImage:[UIImage imageNamed:@"NAV_BG_iphone.png"] forBarMetrics:UIBarMetricsDefault];
rootNavC.navigationBar.translucent = YES;
rootNavC.navigationBar.backgroundColor = [UIColor clearColor];
[[UINavigationBar appearance] setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor whiteColor],
UITextAttributeTextShadowColor : [UIColor clearColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetMake(0, 0)],
UITextAttributeFont : [UIFont fontWithName:@"pastel" size:20]
}];
最佳答案
试试这个
[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];
希望以上代码对您有所帮助。
关于ios - 如何在 IOS 8 中使 UINavigationBar 透明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27228317/