background image fit to screen (swift)

UIGraphicsBeginImageContext(self.view.frame.size)
        UIImage(named: "background.png")?.drawInRect(self.view.bounds)
        
        let image: UIImage! = UIGraphicsGetImageFromCurrentImageContext()
        
        UIGraphicsEndImageContext()
        

        self.view.backgroundColor = UIColor(patternImage: image)
Previous
Next Post »