2
votes

I have a small view that I want him occupy 1/3 height of superview(same size with safe area)

I defined leading space, trailing space, bottom space which its constant = 0 with superview.bottom.

AND I want to make the height 1/3 of superview height to make it same look in all iphone sizes. I defined aspect ratio and changed its first item as superview.height and second item as thisview.height. of course I have defined 3:1 multiplier enter image description here enter image description here

But it doesnt work it gives following error

Terminating app due to uncaught exception 'NSGenericException', reason: 'Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal.

Come on!! why doesnt it work? this is not that complex compared to all other stuff. Also how can I complish this on interface. (not in code) I would like to see it on xcode with all other screensizes in preview tab.

Thanks a lot for your time.

1
please share how you set this view constraints , properly IB screenshootsSh_Khan
Share your autolayout code for the view and other relevant views.Rakesha Shastri

1 Answers

9
votes

Set the view Equal Heights with its superview. Then change the multiplier of the Equal Heights constraint to 1:3

enter image description here