0

I need to set up relative top space of view to its superview. e.g. Suppose top space to view to its superview is 5px and it should proportionately increase for iPhone 7,8,X,Xr etc. I have attached image for better idea.

enter image description here

How can I achieve it?

halfer
  • 19,824
  • 17
  • 99
  • 186
iPhone
  • 4,092
  • 3
  • 34
  • 58

1 Answers1

0

Set IBOutlet of Top LayoutConstraint that you marked in red circle in above image. ans set top according to device.. https://stackoverflow.com/a/11197770/6783598

Ben Rockey
  • 920
  • 6
  • 23
  • Is it possible using interface builder? – iPhone Jul 09 '20 at 07:23
  • If the superview is the full screen (i.e. the height of the device), you could possibly make it a multiplier (like 0.05, i.e. fraction) of the superview's height (or centerY or whatever), rather than a constant offset. But anything more specific/complicated you'll need to do in code. – Carl Lindberg Jul 10 '20 at 16:10