Search code examples
iosautolayoutcoordinate-systems

Is the iOS coordinate system equal across devices?


I've been working through tutorials in order to get the hang of using auto layout. I'd like to start designing more interfaces in code versus using the basic options available in storyboard. However, before I explore this idea, I'd like know if the iOS coordinate system is equal across all devices?

I know that most of the latest and greatest iOS devices have improved retina displays but I'm not sure if that affects the coordinate system.

If the above is true then a second part to this question would be what x and y values can I go up to in the coordinate system before the view is no longer visible?


Solution

  • Obviously different sized devices have different sized screens. The old 3.5" iOS devices were 320x480 points. Then the 4" device were 320x568. And of course all the newer devices are bigger yet. Most iPads are 768x1024 but then there is the iPad Pro, etc.

    And there is the difference between points and pixels. Only worry about points. This hides whether the device is the old non-retina, 2x retina, or 3x retina.

    But none of this is relevant. You don't need to know any of these sizes. That's the whole point of autolayout and constraints. Even with code, you don't need to know absolute sizes. Ask a view its size. Make decisions based on that size. Apply layout based on the size at runtime without any hard coded knowledge of screen sizes.