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

posted on 2015-01-14 17:33  土豆饼  阅读(1452)  评论(0编辑  收藏  举报