Size Classes to distinguish between iPhone 5, 6 and 6 Plus?
Asked Answered
O

2

9

I was very happy to learn that Size Classes are backward compatible with iOS 7 (in some cases). Now I'm wondering - is there a way to use Size Classes to distinguish between iPhone 5, 6 and 6 Plus?

Oeillade answered 7/2, 2015 at 10:54 Comment(0)
G
10

No. Quite the opposite actually, size classes are used to abstract the device away. These are the currently used size class:

compact width, compact height: 3.5", 4", 4.7" iPhones in Landscape mode
compact width, regular height: all currently available iPhones in Portrait
regular width, compact height: 5.5" iPhone in Landscape
regular width, regular height: all currently available iPads regardless of orientation

Guzman answered 7/2, 2015 at 13:16 Comment(3)
I understand, but if i want to make changes in only my iphone3.5 and keep the layout as same for all others, what must i do?Underlayer
It's a problem not being able to e.g. have different font sizes and spacings for iPhone5s and iPhone6s. For certain UI layouts these screens are worlds apart. The size classes are too coarse.Evoke
It is a joke that +3 years later after @JarrodSmith comment, apple still decides that it is fine to keep all iphones in same size class. Its almost as if apple enjoys all the white space most apps have on the bigger phones...Laufer
I
0

You could try testing against the screen height (or width) eg:

//iphone 5
if UIScreen.main.bounds.size.height == 568.0 {
// your code here
}

iphone screen heights are as follows:

iphone 5 = 568.0

iPhone 6/6s/7 = 667.0

iphone 6/7 plus = 736.0

Industrials answered 9/12, 2016 at 15:30 Comment(1)
I'd check for UIScreen.main.bounds.size.height and not for the view sizeSophistry

© 2022 - 2024 — McMap. All rights reserved.