在Swift iOS 8中设置透明导航栏和状态栏的图像底图 [英] Set Image Underlay of Transparent Navigation Bar and Status Bar in Swift iOS 8

查看:309
本文介绍了在Swift iOS 8中设置透明导航栏和状态栏的图像底图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是iOS快速开发的新手,现在遇到了问题.我想设置透明导航栏,并使透明导航栏和状态栏的图像底图像下面的图像一样,

I am new in iOS swift development and I am facing a problem. I want to set transparent navigation bar and make image underlay of transparent navigation bar and status bar like image below,

但是在实现以下代码后,

But after I implemented the following code,

self.navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
self.navigationController!.navigationBar.shadowImage = UIImage()
self.navigationController!.navigationBar.translucent = true

即使将导航栏设置为透明,结果仍然是图像仍在导航栏和状态栏下方.

The result is image still below navigation bar and status bar even though I set the navigation bar to transparent.

推荐答案

我尝试了与您提供的相同的代码:

I have tried same code as you provided:

override func viewDidLoad() {
    super.viewDidLoad()
    self.navigationController!.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: .Default)
    self.navigationController!.navigationBar.shadowImage = UIImage()
    self.navigationController!.navigationBar.translucent = true
}

它运行正常,您可以在这里看到结果:

And it is working fine and you can see result here:

检查我的示例项目,并找出您缺少的内容.

Check my sample project and find out what are you missing.

希望这会有所帮助.

这篇关于在Swift iOS 8中设置透明导航栏和状态栏的图像底图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆