0
votes

I wanted to achieve the following on an iPhone in portrait:

enter image description here

and the following on an iPhone landscape, or iPad portrait/landscape: enter image description here

Would anyone have recommendations based on the new size classes and adaptive layout features for how to do this?

Maybe I need to create two auto layout constraints on box # 4 (the first box in the second row), based on size class? So if it's compact height, but regular width, then a higher priority size class horizontal constraint or something? I'm having a hard time with this =/

Thanks so much!

1

1 Answers

0
votes

I think you can achieve that by creating 2 sets of constraints, the first set will take care of viewing the rectangles in the suitable way for iPhone and it will have low priorities for its constraints (1 for example), and the second set will take care of viewing the rectangles in the suitable way for iPad and it will have high priorities for its constraints (999 for example).

Now, you'll need to check for the device type programmatically and decide the suitable set of constraints to activate.

if UIDevice.current.userInterfaceIdiom == .pad {

    // Set high priorities for the set of constraints that takes care of viewing the rectangles in the suitable way for iPad and low priorities for iPhone set.

} else {

    // Set high priorities for the set of constraints that takes care of viewing the rectangles in the suitable way for iPhone and low priorities for iPad set.
}