How To Use Constraints And Size Classes In xCode 8

By: The Swift Guy

403   14   36290

Uploaded on 10/04/2016

In this video, I show you how to work with constraints and the new feature 'size classes' in xCode 8.

Check out my Swift courses: https://www.udemy.com/user/sehehe/

Comments (5):

By anonymous    2017-09-20

You should look at Size Classes concept. For example, watch this video on youtube to understand how it works. https://youtu.be/7iT9fueKCJM

Also you can setup your constraints programmatically after rotation:

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
        super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)

        if (UIDevice.currentDevice().orientation.isLandscape) {
            // ------ Landscape -----
            // Setup constraints

        } else {
            // ----- Portrait -----
            // Setup constraints
        }
    }

Original Thread

By anonymous    2017-09-20

I am also developing an iOS app, so I understand your problem.

The application doesn't get resized.

The buttons/labels won't be put wherever they should be as Xcode doesn't know where to put them. This is because the screen size varies with each device.

You should use constraints (really good tutorial) to put your buttons/labels wherever you want them to be. Another good tutorial

Original Thread

By anonymous    2018-04-02

Make sure to place the constraints exactly to your view controller size, here is more how to do so video

Original Thread

Submit Your Video

If you have some great dev videos to share, please fill out this form.