iosxcodeinterface-buildernslayoutconstraintsize-classes

Set Different Multiplier Value for Different Size Classes in Xcode Interface Builder?


I have a UIImage. When this UIImage appears on an iPhone I want the height of this UIImage to be 0.5 of the height of the screen. When this UIImage appears on an iPad, I want the hight of the UIImage to be 0.3 of the height of the screen.

I have tried using Interface Builder Size Classes to set a different Multiplier for Compact|Regular and Regular|Regular, but when I change the Multiplier value, it changes across all Size Classes.

Is there a way to set a different Multiplier value for different Size Classes?


Solution

  • Create two equal heights constraints set one with multiplier 0.5, the other with 0.3. Click on the 0.5 constraint, open the size inspector, unclick installed, click the plus next to the installed checkbox, select compact|regular/any. Do the same for the 0.3, but select regular|regular.