Make UINavigationBar transparent
1、使用统一的背景图片
在AppDelegate.swift中添加如下代码:
var img=UIImage(named:"background.jpg") var imageView:UIImageView?
self.imageView=UIImageView(frame: self.window!.frame) self.imageView?.image=img self.window?.addSubview(self.imageView!) //self.window?.backgroundColor = UIColor(patternImage: img!)
2、在其中一个ViewController中添加:
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default) self.navigationController?.navigationBar.shadowImage = UIImage() self.navigationController?.navigationBar.translucent = true
3、所有的View的Background设置成Clear Color
时间: 2024-11-10 06:03:50