How to make a different design for smaller iPhones and iPhone 6 plus using size classes?

Is it possible to do a different design in Interface Builder for iPhone 6 plus and other iPhones using size classes? I only need portrait mode.

According to some tutorials ( http://swiftiostutorials.com/using-size-classes-xcode-6/ ) it seems like this should be possible. Also in IB Compact + Any for small iPhones:

enter image description here

and Compact + Regular for all iPhones:

enter image description here

But when I try to get another design it doesn't work. For example, how to hide the view for small iPhones and show it for iPhone 6 plus? enter image description here

+3


source to share


2 answers


Unfortunately, you can only do this for landscape (where the iPhone 6 plus has a different collection of features than the rest of the iPhone family).

The way it is phrased in IB is in some ways misleading. You are correct waiting for w Compact h Regular to rewrite the rule for w Compact h Any. The problem is that the iPhone 6 plus is categorized as w Compact h .

Printing a collection of visibility objects when working on the iPhone 6 plus confirms this:

<UITraitCollection: 0x7f968ada42c0; _UITraitNameUserInterfaceIdiom = Phone, _UITraitNameDisplayScale = 3.000000, _UITraitNameHorizontalSizeClass = Compact, _UITraitNameVerticalSizeClass = Regular, _UITraitNameTouchLevel = 0, _UITraitNameInteractionModel = 1>

      



These two, in particular:

_UITraitNameHorizontalSizeClass = Compact, _UITraitNameVerticalSizeClass = Regular

      

You can change / override traits at runtime (ie tell the view "no matter what you think, I say you have compact height, etc."), but for your case, I would just include screen height and hide views manually based on this information.

+2


source


In portrait orientation, you cannot use size classes to differentiate between iPhone 6 and 6+. You will need to do this programmatically by checking the screen height after your view has loaded.

The Human Interface Guide shows that both phones have the same collection of features in portrait: Compact Width / Normal Height . The collection in your first image is compact width / any height that includes compact width / regular height - why can't you see the difference if you set the view in one and not the other.



Not applicable to your case, it's worth noting that you can differentiate between the two devices in landscape orientation, as the 6+ uses standard width / compact height, but smaller phones use Compact width / Compact height.

+1


source







All Articles