I have 3 rectangles and the size and placement of them is perfect... on the iPhone 6 and 7 plus. When I run this on a smaller iPhone or an iPad it looks all wrong.
I could make a huge if statement at the beginning of my app to check the device, then assign values to variables accordingly, but there has to be a better way, right? How do most apps size and position everything so the app looks pretty much the same on every device?
let blueRect = UIView(frame:CGRect(x: self.view.frame.size.width / 2 - 100, y: 100, width: 200, height: 100))
blueRect.backgroundColor = UIColor.blue
self.view.addSubview(blueRect)
let greenRect = UIView(frame:CGRect(x: self.view.frame.size.width / 2 - 100, y: 300, width: 200, height: 100))
greenRect.backgroundColor = UIColor.green
self.view.addSubview(greenRect)
let redRect = UIView(frame:CGRect(x: self.view.frame.size.width / 2 - 100, y: 500, width: 200, height: 100))
redRect.backgroundColor = UIColor.red
self.view.addSubview(redRect)