Reputation: 2654
First apologies in advance for question as it does not require coding only if its the required solution.
I am walking my way through constraints and auto resize with swift 4. I am having one slight issue while auto resizing without using constraints as that messes up the buttons positioning and size. See below how my UI buttons stack up.
iPhone 8 Plus, iPhone 8, iPhone SE all look same and buttons aligned perfect
iPhone X - Image appears stretched
iphone 4S - Image appears compressed inward
All I did was for each button set autoresizing as seen below
Is there a way I can make iPhone X maintain same image aspect ratios?
Thanks
Upvotes: 0
Views: 644
Reputation: 890
As stated in the comments, you should use constraints to achieve the desired result. Using aspect-ratio
and proportional
constraints you should be able to scale the buttons accordingly.
EDIT
There are many ways you can do this with autolayout. Below I enumerate each step I performed to achieved it.
There will be some storyboard errors, don't worry, we will fix them shortly.
That's it, now you should add buttons and/or images to each view and perform additional logic to achieve your desired final result (adding round corners and such).
Upvotes: 4