How to set a background image in Xcode using swift?

后端 未结 8 923
感动是毒
感动是毒 2020-12-23 13:08

How can I set a background image for my main view controller in Xcode 6 using swift? I know that you can do this in the assistant editor as below:

overri         


        
相关标签:
8条回答
  • 2020-12-23 14:07
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = UIColor(patternImage: UIImage(named: "background.png"))
    }
    
    0 讨论(0)
  • 2020-12-23 14:08

    SWIFT 4

    view.layer.contents = #imageLiteral(resourceName: "webbg").cgImage
    
    0 讨论(0)
提交回复
热议问题