Transclucent导航栏移动部分标题

时间:2015-12-02 22:48:42

标签: ios objective-c xcode swift uinavigationbar

我只是一个很难找到半透明导航栏的人。 我试图在appDelegate和特定的ViewController中设置它。 我最终得到的是: 有谁知道为什么白色部分标题被移动了?当我滚动并且我无法为其设置颜色时,导航栏甚至不是半透明的。 (我可以在半透明=假时设置颜色) 我试图将它设置为半透明和不透明,并在故事板中推断。(不工作)

更新

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

部分标题之间是半透明的,但顶部栏不是!

UPDATE 2

1 个答案:

答案 0 :(得分:0)

如果您尝试在整个应用中为navigationBar设置半透明背景,可以在application:didFinishLaunchingWithOptions

AppDelegate方法中使用以下代码
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()
  

结果截图:

enter image description here

相关问题