XCode: How to resize views, buttons depending on the screen size of the device? - ios

My app contains several view controllers. I have used auto layout to add constraints to my labels, views and buttons.
This is how one of the screens looks like on iPhone X.
How the sam screen looks like on iPhone 8
As you can see, the disclaimer text in the iPhone 8 image is not fully showing.
How would I get it to show on iPhone 8, iPhone SE, etc?
Thank you

Related

Layout missed up on 3.5" Screen iPhone 4

I have developed my App on XCODE 8 which by default removes iPhone 4 emulator and I didn't notice that until I finished my app, and I used Auto layout to make the UI fits all iPhone screens and that what happened (the layout was good on iPhone 7,6,5) the problem is when I additionally installed iPhone 4 emulator I found that the layout is totally missed up and unreadable/usable.
So what options do I have to solve this and make it fit the iPhone 4 screen too with Auto-Layout with missing up the other sizes ?
Here is screen shot of my Login screen on iPhone 6 (4.7") vs iPhone 4 (3.5")
You must always give constraints with respect to other alternative buttons or a view, it should not be hard coded. Try making views programatically, it will be more easy and helpful to you.
It seems like your constraint is set to have a fixed distance related to the top of your screen. So when the screen height get smaller, your views are pushed out of the screen. So to better adjust views position, you can have your views to be related to vertical center. Say your login box is in both horizontal and vertical center, not metter you are using iphone 6 or 4, you should always see your login box.

Different layout for the same size class and almost the same view's width across devices

Situation on below image shows the problem. There are two devices: iPod and iPad Pro. On iPad Pro there is split view with my app on the right site. My app uses UISplitViewController for appropriate screen width.
Why it makes difference as you can see in the image below?
Is there a way to change constraints somehow depending on size classes or sth else excluding screen width?

How to let Xcode know which asset to use for the target iPhone?

I am designing an app for iOS in SWIFT. I have decided that the auto layout will be compact and will be only for iPhone in portrait mode. I wanted to clear up a few hiccups on designing buttons for the 2 different screen ratios: the first being the iPhone 4s and the second ratio being the iPhone 5 and above. Because the new iPhones have a taller height, does that mean I will need to design 2 different ratios of buttons, and if so, how do I use them in Xcode? For example here's the stock apple calculator;
link to picture: http://imgur.com/mkIBghD
As you can see the the buttons on the taller iPhone have a square shape. The buttons on the 4s are more stubby. What do I need to do in Xcode to let the app know which asset to use for the respective phone and how would I implement that in Auto Layout?
thanks
In order to do this you setup autolayout constraints. This will make the buttons change shape/size depending on the device. You do not need to have multiple assets because all the phones you are talking about have the same retina (2x) display.
You need to add three different sized images for a single Image Set in Images.xcassets . The sizes should be 1x for iPhone 4s, 2x for iPhone 6(It'll work for iPhone 5 too) and 3x for iPhone 6 plus.

Displaying different images for iPhone 4 & 5

This seems to be an interesting problem that I'm getting. I'm developing an iPhone app for iOS 6+ devices and optimizing the images for both iPhone 4 & 5. Now I have implemented this into my project: Xcode 4.5 background image iPhone 4, 4s, 5
The problem is in interface builder I'm designing the UI with the iPhone 5 screen, so the UIImageView is 320x568. But when I test on iPhone 4, the image is being stretched and looks terrible. However, the specified image for the iPhone 4 screen is displaying, i just want its dimensions to be 320x480
Hope someone can help!
From the inspector view in the interface builder, you can edit the stretching behavior of the view when the size of the super view changes. You can click the red arrows inside the square to control that.
Also I suggest that you check UIView contentMode. You can edit that from the inspector view in the interface builder "third tab from the right.
In the UIImageView's inspector, try playing with the Mode property. The Aspect Fill or Aspect Fit may get what you're looking for to handle the different screen sizes.

Two storyboards for different iPhones (3,5 and 4')

I write application for a 3.5-inch on one storyboard and for 4 inches in another stroryboard. As a delegate at startup check under what device is enter in and from there method can be carrying launch storyboard or iphone 4 or iphone 5
(because the larger screen iphone 5, can I expands the functionality?)
Is it correct?
You don't have to do this. There is a button in the bottom left of interface builder that lets you switch between screen sizes, and using autosizing will adjust it for both screen sizes.
You can also use Autolayout too

Resources