I need to have specific sets of constraints for iPhone X family and another for other models of iPhone. I select a constraint, select a device family and use vary for traits. Looks like vary for traits is very specific to only trait collection (Regular/Compact x Regular/Compact). Is it not possible to have constraints for device family (iPhone X, XR, XS max, etc.)? What if I want to have completely different interface layout for iPhone X family, is it possible in Storyboard?
Asked
Active
Viewed 827 times
1 Answers
0
For sorry you can't , you need to create constraints proportionally ( width / height ) in IB or detect device family in code and supply the needed constraints

Shehata Gamal
- 98,760
- 8
- 65
- 87
-
Problem is for non iPhone X models, I need the bottom constraint of subview to be 10 with respect to main view. On iPhone X family, there is tremendous space available in landscape mode. I can easily go -2 and still be above the home indicator. – Deepak Sharma Nov 22 '18 at 15:11
-
then drag that constraint and configure it in code no trait for this – Shehata Gamal Nov 22 '18 at 15:13
-
How do I do that exactly for specific device family, please let me know – Deepak Sharma Nov 22 '18 at 15:14
-
check this https://stackoverflow.com/questions/46192280/detect-if-the-device-is-iphone-x/47067296 – Shehata Gamal Nov 22 '18 at 15:16
-
This is about detecting device type. Do I need to set the constant in code you mean? Not possible in Storyboard to have different layout for device family? – Deepak Sharma Nov 22 '18 at 15:18
-
set it's not possible in Ib , so set the constant in code according to the switch size – Shehata Gamal Nov 22 '18 at 15:19
-
Ok thanks. So if I have completely different layout for iPhone X, is there any way in Storyboard? – Deepak Sharma Nov 22 '18 at 15:20
-
No there isn't , What you need is a good feature that Apple may add as the X family are growing and now there are alot of specific stuff for them but for sorry there is no trait for them in IB till Xcode 10 – Shehata Gamal Nov 22 '18 at 15:25
-
What is the way to achieve it? Lets say I wish to show screen1 on iPhone X and screen2 on iPhone 8, both with different layouts. Is there a way to configure and save two layouts in Storyboard, and then load the appropriate one on device? Screen1&2 may have common UI elements. – Deepak Sharma Nov 22 '18 at 16:07