Skip to content

Instantly share code, notes, and snippets.

@Pasanpr Pasanpr/frame.swift Secret
Created May 31, 2016

Embed
What would you like to do?
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
}
}
@TenzinSean

This comment has been minimized.

Copy link

TenzinSean commented Sep 29, 2016

thanks Pasan .. i enjoy your swift course.

@DevinBoddie

This comment has been minimized.

Copy link

DevinBoddie commented Mar 28, 2017

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
You can’t perform that action at this time.