iOS Size Classes and Adaptivity Size Classes and Adaptivity through Storyboard

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

We can add adaptivity to any subclass of UIView which we add on view controller in nib file.
Lets take an example of adding adaptivity using size classes to a view.

  1. Add a view on view controller as:

enter image description here

  1. Now we need to pin this view to it's superview for fixing it's size and position using constraints as:

enter image description here

  1. We can see the added constraints as:

enter image description here

These constraints defines that the added view will be placed in it's superview as

CGRect(20, 0, superview.width - 20, superview.height - 20)
  1. To see the preview on screen of these added constraints we can use Assistant Editor as;

enter image description here

  1. We can add more screen to see preview like:

enter image description here

We can also see the preview with landscape mode by moving mouse on the name of device and clicking the rotation button as:

enter image description here



Got any iOS Question?