Bob Williams Bob Williams - 1 year ago 112
Swift Question

how to make contents in my app universal?

I have made an app that fits all my contents perfectly on Iphone 6, but when I run it on any other device, the positions are shifted. How do I fix this using UIKit on Xcode

Answer Source

make the size and position relevant to the screen size for example:

Image.position = CGPoint(x: (scene?.size.width)! * 0.1, y: (scene?.size.height)! * 0.2)

Image.size = CGSize(x: (scene?.size.width)! * 0.6, y: (scene?.size.height)! * 0.6)

i use scene as a reference majority of the time but frame size works as well by replacing the (scene.size.height)! portion with

(self.frame.size.width) or (self.frame.size.height)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download