我只是一个努力获得半透明导航栏的简单人。 我尝试在 appDelegate 和特定的 ViewController 中设置它。 我最终得到的是这样的: 有谁知道为什么白色的部分标题向下移动?当我滚动时,导航栏甚至不是半透明的,而且我无法为其设置颜色。 (当半透明= false时我可以设置颜色) 我尝试将其设置为半透明和不透明,并在 Storyboard中推断。(不起作用)
更新:
let colorImage = imageFromColor(UIColor(red:0.22, green:0.23, blue:0.29, alpha:0.5), frame: CGRectMake(0, 0, 340, 64))
self.navigationController!.navigationBar.setBackgroundImage(colorImage, forBarMetrics: UIBarMetrics.Default)
self.navigationController!.navigationBar.shadowImage = colorImage
self.navigationController!.navigationBar.translucent = true
colorImage 是我用 rgb-uicolor 制作的图像。结果是这样的:navigation bar 2
节标题之间是半透明的,但顶部栏不是!
最佳答案
如果您尝试在应用程序中为 navigationBar
设置半透明背景,则可以在 AppDelegate
application:didFinishLaunchingWithOptions
方法中使用以下代码
let colorImage = getImageWithColor(UIColor(red:0.22, green:0.23, blue:0.29, alpha:0.5), size: CGSizeMake(360, 64))
UINavigationBar.appearance().setBackgroundImage(colorImage, forBarMetrics: UIBarMetrics.Default)
UINavigationBar.appearance().translucent = true
UINavigationBar.appearance().tintColor = UIColor.whiteColor()
Result Screenshot:
关于ios - 半透明导航栏移动部分标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34054593/