Skip to content

Instantly share code, notes, and snippets.

@Pasanpr
Created May 31, 2016 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pasanpr/6b47fd38c43cd554c3cb9b459df0c5e5 to your computer and use it in GitHub Desktop.
Save Pasanpr/6b47fd38c43cd554c3cb9b459df0c5e5 to your computer and use it in GitHub Desktop.
override func viewWillLayoutSubviews() {
if UIDevice.currentDevice().orientation == .LandscapeLeft || UIDevice.currentDevice().orientation == .LandscapeRight {
var rect = greenView.frame
rect.origin.x = 20
rect.origin.y = 20
rect.size.width = 307
rect.size.height = 161.5
greenView.frame = rect
rect = redView.frame
rect.origin.x = 340
rect.origin.y = 20
rect.size.width = 307
rect.size.height = 161.5
redView.frame = rect
rect = yellowView.frame
rect.origin.x = 20
rect.origin.y = 193
rect.size.width = 307
rect.size.height = 161.5
yellowView.frame = rect
rect = blueView.frame
rect.origin.x = 340
rect.origin.y = 193
rect.size.width = 307
rect.size.height = 161.5
blueView.frame = rect
} else {
var rect = greenView.frame
rect.origin.x = 25
rect.origin.y = 44
rect.size.width = 160
rect.size.height = 299
greenView.frame = rect
rect = redView.frame
rect.origin.x = 191
rect.origin.y = 44
rect.size.width = 160
rect.size.height = 299
redView.frame = rect
rect = yellowView.frame
rect.origin.x = 25
rect.origin.y = 348
rect.size.width = 160
rect.size.height = 299
yellowView.frame = rect
rect = blueView.frame
rect.origin.x = 191
rect.origin.y = 348
rect.size.width = 160
rect.size.height = 299
blueView.frame = rect
}
}
@TenzinJhopee
Copy link

thanks Pasan .. i enjoy your swift course.

@DevinBoddie
Copy link

Hi Pasan!

This code no longer appears to work in XCode Version 8.2.1 (8C1002).
Copy and pasted directly and getting tons of errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment