Autolayout Programmatically
This article continues from the previous article. Earlier we saw how we can make iOS Apps without using the storyboard file. In this article we will explore how to implement Autolayout programmatically. We will continue from the previous article.
The code that I will be showing in the article will not be covering all the possible cases. The point of this article is to give you an idea on how to implement the different Autolayout solutions. Feel free to play around with the code to cover all the cases & situations.
Programmatic Constraints
We have 3 options when it comes to applying constraints programmatically:
- StackViews
- Layout Anchors
- NSLayoutConstraints class
- Visual Format Language (VFL)
Handling Size Classes in code
Handling Size classes in code is fairly easy. It is a simple question of overriding the correct function. We will look at this in greater detail when we cover the topic later in the article.
Topic | Page |
---|---|
Implementing UIStackViews | 2 |
Implementing Layout Anchors | 3 |
NSLayoutConstraints class | 4 |
Implementing Visual Format Language | 5 |
Size Classes | 6 |
Summary & Video | 7 |
This article has been written using Xcode 10.3.
Fixed the issue with the links to the sample projects. They should be working fine now.