Auto Layout Tutorial in Xcode with Swift for iOS 10 | iOS Development Tutorial


Have you ever wanted to build universal apps meaning you build 1 app UI that can work on any screen size? That’s what Auto Layout in iOS will help you.

In this Auto Layout tutorial, you’ll learn:
+ What’s Auto Layout
+ How to add unambiguous constraints
+ Different kinds of constraints in Auto Layout.
+ Priorities in Auto Layout Constraints
+ How to programmatically create auto layout constraints
+ What’s Auto Layout Content Hugging Priority vs. Content Compression Resistence Priority
+ Stack View in iOS
+ How to create and use UIStackView with Auto Layout

First off, let’s download the starter project Duc prepared for you. Just simply enter your name and email on the page to get:
+ the starter and complete projects of this episode
+ Duc’s step-by-step video tutorial
+ Duc’s new training on How to Build Nike E-commerce Store WITHOUT Losing Your Shirt

It’s all awesome iOS development training for you, for FREE!


Code Mastery is hosted by Duc Tran, founder of Developers Academy.

This is his free-style no notes, no teleprompter presentation and live coding broadcast with you guys everyday.

To join Duc’s free courses, register for free at


Duc Tran is founder of Developers Academy, one of the world’s leading iOS, Android and Web development trainers.

More than 2,000,000 developers have studied his video trainings; 100,000 developers see his posts each month. Each year, Duc has helped 20,000 plus developers graduate from his online courses or video series.

To subscribe and get free tutorials, courses and weekly content, visit me at:
Connect with Duc on facebook:
Tweet him:
Get daily inspiration:



class NetworkProcessor
lazy var configuration: URLSessionConfiguration = URLSessionConfiguration.default
lazy var session: URLSession = URLSession(configuration: self.configuration)

let url: URL

init(url: URL)
self.url = url

typealias JSONDictionaryHandler = (([String : Any]?) – Void)

func downloadJSONFromURL(_ completion: @escaping JSONDictionaryHandler)
let request = URLRequest(url: self.url)
let dataTask = session.dataTask(with: request) { (data, response, error) in

if error == nil {

if let httpResponse = response as? HTTPURLResponse {
switch httpResponse.statusCode {
case 200:
// successful response
if let data = data {
do {
let jsonDictionary = try JSONSerialization.jsonObject(with: data, options: .mutableContainers)

completion(jsonDictionary as? [String : Any])

} catch let error as NSError {
print(“Error processing json data: (error.localizedDescription)”)


print(“HTTP Reponse Code: (httpResponse.statusCode)”)

} else {
print(“Error: (error?.localizedDescription)”)


Full access to source code:

Episode tags: duc tran,, developers academy, REST, REST API, REST API in ios tutorial, ios REST API, how to parse json, parse json in ios, parse json, parse json swift, parse json swift tutorial, parse json in Swift, alamofire, alamofire tutorial, uicollectionview, json ios, ios json parsing, ios json, ios json tutorial, json swift tutorial, swift json tutorial, parse json in ios,swiftyjson, nsurlsession, urlsession, firebase, alamofire, alamofire tutorial, alamofire swift tutorial, auto layout xcode,auto layout constraints,ios auto layout,duc tran,, how to make an app,how to build an app,how to build ios app,xcode tutorial,swift tutorial for beginner,how to build an ios app, how to build an ios app in swift, xcode storyboard tutorial,build ios app xcode,auto layout table view






36 responses to “Auto Layout Tutorial in Xcode with Swift for iOS 10 | iOS Development Tutorial”

  1. hientienlen hien Avatar

    Great tutorial about auto layout. Thank you very much

  2. Lee Yvonne Avatar

    Thank you ! Now I understand how does auto layout work with your demo and clear explanation. Can I share this video on my blog ? Thank you again !

  3. Vu Pham Avatar

    It seems that you're from Vietnam 😀
    Anyway you're awesome, thanks so much

  4. satheesh kumar Avatar

    I want auto layouts for realtime screen like signup or sigin screen are else complicated screen

  5. Paul Dinakaran Avatar

    Great explanation, it helped lot Thanks Duc

  6. Angle Bela Avatar

    How to do all that in this video with code ??
    Please recording vide like this but with write code
    Thanks 🙂

  7. Christopher Presley Avatar

    I agree with Nadeem. You really did a good job explaining Auto Layout and Constraints. Thanks so much!

  8. Knowideer Avatar

    Great tutorial dude. auto layout is a lot clearer to me know. quality of vid is great also. nice job!

  9. hunTR00 Avatar

    You are a good guy ! You explain great!
    Your accent is cute 😀

  10. Horacio Canales Millan Avatar

    excellent video, still i got some problems…..
    i got a question, which dispositive is preferible to make this constraints?
    am trying to do an app in iPad, and when i check on iPhone is a disaster :s (and all the blue lines are there and "happy" but when i check in iPhone its not :S)

  11. Hiên Phùng Khánh Avatar

    Hay quá anh ơi. Em từ bên Android chuyển qua, AutoLayout quả là ác mộng.

  12. Mahendra Patil Avatar

    thank you very much

  13. Ali Sher Avatar

    That's a simple view .. do autolayout of a complicated view.. there is only 1 logo 1 label and 1 button its so simpe,, so please deliver tutorial for complex view…

  14. Gypsum Hong Avatar

    you save my life !

  15. Shrikala Nayak Avatar

    great works.. helps me alot

  16. Marcus Paulo Avatar

    Thanks, great tutorial.

  17. Adam El-Kadi Avatar


  18. Bill Kwaku Ansah Inkoom Avatar

    Thanks. This really enlightened me

  19. Ju Young David Kim Avatar

    Hey for the logo constraints, if you set the height and width like you did in your video, the logo becomes too big for smaller screen. Is there anyway to make it scale?

  20. Min Thu Avatar

    thank you so much for your video. Yet, I wonder if this will work for landscape view.

  21. Bilal Baydoun Avatar

    Wow! amazing tutorial!

  22. Rafael Paz Avatar

    That was an excellent explanation, mate! I've been struggling to understand that. Cheers!

  23. Abhilash Reddy Avatar

    Good job Duc Tran and thank you so much. I'm glad that finally I've found this video !! While watching this, I felt like unlocking a treasure!!

  24. Aagha Abdul Waheed Avatar

    You are Awesome Bro. Thanks 🙂

  25. Sourov Datta Avatar

    Simply good package of autolayout ! Thanks
    Would you make another tutorial on advance topics of autolayout .

  26. val vall Avatar

    in my company previously storyboard has entirely made by autoresizing mask,now i can't able to change it to autolayout .
    can u help pls

  27. hazem abdulrab Avatar

    yes great explanation ..very easy to understand

  28. Infaz Ariff Avatar

    Please upload a video to show How to use Aspect Ratio when doing AutoLayout

  29. Nadeem Khoury Avatar

    Thank you so much broo ,, I have watched a lot of courses about auto layout but nobody explained it as you did

  30. Rizwan Ahmed Avatar

    You are doing a very good job Duc, Keep it up ! 🙂

  31. ال تميمي Avatar

    Can you please make a tutorial on how to make an app similar to whatsapp, snapchat and instagram? and also make a tutorial on how to update your old applications please.

  32. Nikhil Boriwale Avatar

    i subscribe Ur channel sir..

  33. Nikhil Boriwale Avatar

    help full video sir…

Leave a Reply

Your email address will not be published. Required fields are marked *