Home » Android » android – How to do match_parent in iOS

android – How to do match_parent in iOS

Posted by: admin June 15, 2020 Leave a comment

Questions:

I am used to having an Android background where I do:

android_layout_width="match_parent" or android_layout_height="match_parent"

How is this behavior done on iOS, using xib?

How to&Answers:

1) Set frame of child view matching parent’s view bounds.
2) Enable autoresizing mask like in screenshot.

enter image description here

Answer:

You have to create two constraints from the child to it’s parent view:

  • equal width
  • equal height

UIB define constraint

It’s also possible to define a margin (select the created constraint within the size inspector)
enter image description here