15

I upgraded my Xcode today to 11 and just realised that Xcode doesn't allow me to create proportional height from a sub view to the view controller's root view anymore. I was able to do it till this morning with the previous Xcode version. The only workaround is to add another sub root view to the controller and move everything under it. This option will take too much time to re-design the setup the controller.

Are you experiencing the same problem?

This is from the new Xcode 11. As you can see there is no equal height or width option to superview anymore.

enter image description here

And this pic is from one of my Views that I created it's constraint in previous Xcode. As you can see there is a proportional constraint equals to the ViewController's superview with 0.65 ratio.

I don't wanna add a mid root view to the view controller. It will be just a time wasting process. Any ideas? Am I missing a new magic button or +?

enter image description here

thus
  • 1,326
  • 1
  • 14
  • 23

4 Answers4

17

You can set your view equal to the Safe Area.

enter image description here

If you still rely on having it equal to the root view itself, you can modify the constraint in the Attributes Inspector:

enter image description here

Eilon
  • 2,698
  • 3
  • 16
  • 32
  • 1
    Thank you for your suggestion @Eilon it is actually a good solution. But I am not using the Safe Area and I was able to do this without it in Xcode 10. If this is the new requirement of Apple then I can't say anything. I am still thinking it is still a bug because my previously created constraints are supported by Xcode 11 and of course I am not deleting them otherwise I can't re-create them. – thus Sep 26 '19 at 13:02
  • See also how to create [“Width equals height” constraint in Interface Builder](https://stackoverflow.com/a/16089935/8740349) – Top-Master Mar 31 '21 at 09:52
8

I have sent a bug report to Apple yesterday and also found the following discussion in Apple forums. I don't think I am the only developer experiencing this issue.

Xcode 11 Add "Equal Width to Superview" Constraint?

I am sure Apple will create a patch for this problem soon. So I decided to create a temporary solution by adding a new UIView named "Propotional View Helper" right under the root view. I gave trailing, leading, bottom and top constraints to its superview. Now I a able to drag to make equal width & height constraints to the superview.

enter image description here

enter image description here

thus
  • 1,326
  • 1
  • 14
  • 23
  • This is honestly infuriating. Second "breaking" issue with Xcode 11 (first one would be the UITextField crash under Xcode 11.2 with iOS < 13.2). Thanks for your workaround, I'll have to do something similar as well. – cumanzor Nov 02 '19 at 21:57
1
  1. First do "Equal Widths " to any other UIView element .

  2. Go to Attributes inspector of the equal width contraint .

  3. Replace the Second Item with Superview.Width.

credits: https://forums.developer.apple.com/thread/123284

Levan Karanadze
  • 739
  • 1
  • 11
  • 21
1

In "Show the File inspector" tab, under Interface Builder Document enable "Use Safe Area Layout Guides" and set the view equal width or height to "SafeArea".

Screenshot

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41