Skip to content

Instantly share code, notes, and snippets.

@ahikmatf
Created October 24, 2016 03:47
Show Gist options
  • Save ahikmatf/4d47d35b4f019c248a3502e782d452f1 to your computer and use it in GitHub Desktop.
Save ahikmatf/4d47d35b4f019c248a3502e782d452f1 to your computer and use it in GitHub Desktop.
// detect device orientation
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.current.orientation.isLandscape {
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "back-landscape")!)
} else {
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "back-potrait")!)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment