Skip to content

Instantly share code, notes, and snippets.

@asiviero
Created June 10, 2015 18:57
Show Gist options
  • Save asiviero/c9e63b3607bf58373cab to your computer and use it in GitHub Desktop.
Save asiviero/c9e63b3607bf58373cab to your computer and use it in GitHub Desktop.
Background image to view in Swift
UIGraphicsBeginImageContext(self.view.frame.size);
var image = UIImage(named: "image")
image?.drawInRect(self.view.bounds)
UIGraphicsEndImageContext()
// This could also be another view, connected with an outlet
self.view.backgroundColor = UIColor(patternImage: image!)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment