Hello! I´m trying to make an app that will look close to identical for every iPhone device? Let’s say that I want to place a UIView with the distance from the top according to (view.bounds.height * (2/5)). Right now I´m edit the constraints through the code to make it work but it feels like i missing some great autolayout feature?
Which is the best way to handle this?
Thanks on forehand
Hi @karllidar, the question you are asking is precisely what Auto Layout is intended for
If you are building your app using storyboards, then you can adjust your constraints there. However, it sounds like you’re building your UI in your code which is perfectly fine. What you would do is set the height constraint to whatever value you wish to set, from your UIView, to the super view (i.e. the parent, enclosing view of your screen). Having said that, you also mentioned that it feels like you’re “missing some great Auto Layout feature”. What makes you say that? Is there a problem with how your view is being displayed?
As well, please do check out our video series if you haven’t already on Auto Layout:
Beginning Auto Layout
Mastering Auto Layout