size classes for portrait only iphone Apps? - ios

I had an application which is used for portrait only iphone.So i set the size classes to compact width and regular height as suggested.But when i am adding an imageview which is 400*800 and its 2x,3x its not showing properly in iPhone 4s.But it is not showing correctly in 3.5 inch phones,I am getting this in launch screen storyboard which i filled with one imageview.Can anybody guide me in right direction in achieving this ?

Size classes are based on ratio of width and height, not size. In portrait, iPhone 6, iPhone 5, and iPhone 4s all use the compact horizontal and regular vertical size classes. So They could look different on each.
When you design UI Interface for 3.5 inch iPhone in Storyboard, you should set the Size to iPhone 3.5-inch in Attributes Inspector. By doing this, we ensure what we will see in simulator is same as in Storyboard.
Sometimes, You may need to make size class specifically for portrait 3.5 inch (iPhone 4S).Then you need to set auto layout according to the size of screen, like:
if (UIScreen.mainScreen().bounds.size.height == 480) {
//Set your auto layout here
}

Related

Which size class do I use for Portrait/PortraitUpsideDown app

So i'm making a universal devices app but not sure which size classes to use for iPhone and iPad but i'm making the app Portrait and PortraitUpsideDown only.
Do I use 2 size classes one for iPhones and another for iPad or do I use 1 size class for iPhone and iPad?
What size classes do I use if I want iPhone and iPad in Portrait and PortraitUpsideDown?
you have to use different size classes for different layout .According to apple it has 4 type
for iPad (landscape and portrait mode)-regular height and regular width
for iPhone (portrait) - compact width and regular height
for iPhone in landscape(except iphone6 plus and iPhone 7 plus)- compact height and compact width
for iphone6 plus and iPhone 7 plus (landscape mode) - regular width and compact height
---> you are using only portrait mode so you can use
Regular height , regular width for iPad portrait
Regular height , compact width for iPhone portrait
for more information
https://medium.com/if-let-swift-programming/size-classes-ipad-portrait-landscape-55f59173c65a
Portrait and portrait upside down are the same in terms of size classes. Compact width and regular height is for all iPhones in portrait and regular width/regular height is for all iPads in either orientatation

Spacing layout elements with adaptive layout from iPhone 4s to iPhone 6+

I'm attempting to build a view (iPhone only, portrait view only) using adaptive layout. It should all be on a single screen (ideally no scrolling). I've managed to get it working (reasonably) for the iPhone 5 - 6+. However, my issue comes with the 4s.
I'd like, on the iPhone 4s to have the center image go away, which I thought I could use size classes, but it doesn't seem so for the various iPhones in portrait mode (only if I switch orientation).
Additionally, I'd like there to be more padding between all the elements on the 6+ while spacing remains the same on the 5 and 6.
No matter what sizes all iPhone in portrait mode is regular height compact width so size class won't help you here.
To change padding constraint
make the ones you want to change IBOutlets
and in viewDidLoad for example change the NSLayoutConstraint's constant value based on screen height.
For iPhone 4S you can
hide the center imageView
deactivateConstraints all it's constraints
and activate new constraint between the view above imageView and below imageView if needed

iOS User Interface for different devices in iPhone 4, 5, 6+ and iPad

From what I know the resolution in iPad is higher than iPhone therefore the same width and height point in storyboard in iPhone will appear to be bigger in iPad. However, I didn't notice the size differences and it seems to be the same which look the same in iPad.(the height of textfield)
Are there any ways for making them scale in the same aspect fit? By right elements in iPad should be bigger due to the resolution. Autolayout has been used in the following picture.
How do I code for user interface for iPhone 4 and iPhone 6+? The same box will appeared to be too big in iPhone 4.

How do I handle iPhone 6S Plus's font size?

iPhone 6S Plus's screen is very big compared to other screen sizes. I can't seem to find a good way to handle the font size of a label without adjusting the size programmatically.
How can I adjust the font size of a label so that it looks smaller on an iPhone 5 and bigger on an iPhone 6 Plus?
Don't change font sizes for the iPhone 6 or iPhone 6+.
People buy these phones to see more content. The 6+ displays things slightly bigger than the other phones anyway (yes, it has bigger pixels, not just more pixels), and if a user wants an even bigger display they can switch the whole phone to zoom mode (both 6+ and 6; this turns a 6+ into a large 6, and a 6 into a large 5).
Just use autolayout to position things relative to the screen size.
You can't target iPhone 6 Plus using AutoLayout because it's not meant for hardcoding sizes. You either need to use code and do something like this:
if UIScreen.mainScreen().bounds.size.width == 375 {
// iPhone 6
label.font = label.font.fontWithSize(20)
}
or just create a invisible view and set top and bottom constraints to it.
I think it is better to use adaptive fonts (here is an example, section Adaptive Fonts)

Auto layout 3.5 - 4 inch screen as well as ipad mini to normal?

I know to go from the 3.5-4 inch screen with the app you create you have to use auto layout to make it nice on both screens. I was wondering if you had to do the same for the ipad mini - ipad? When i go into the attributes inspector there is no ipad mini choice on the view controller like there is for the 3.5 inch display. With the ipad story board is it a one size fits all type of thing or should I still use auto layout?
Thanks
Shen Hutah
The reason for resizing with the 3.5-4 inch screens is due to a changed aspect ratio. With iPad and iPad mini, they have the same aspect ratio (4:3), so the screens are functionally the same. Unless you're altering the view based on autorotation, there's technically no need to use autolayout.

Resources