How to properly use size classes when building the UI programmatically (using SnapKit)?

1.9k Views Asked by At

I have decided to create my UI programmatically as oppose to storyboards to avoid merge conflict nightmares and a few other things. However, I'm running to a few problems:

  1. How would I do size classes?
  2. My viewDidLoad methods are usually very large which reduces the readability of the code. Any suggestions or best practices?
1

There are 1 best solutions below

1
On BEST ANSWER

1) Using size classes programmatically,
Programmatically implementing two different layouts using size classes,
http://www.digistarters.com/swift-autolayout-and-size-classes-programmatically
2) Constraints may take a big place in your viewDidLoad method if you create all of this programmatically. I moved from fully-coded-UI to xibs and storyboards couple of years ago, and now my life much easier. Also, when view controller becomes too long, you can try this methodology Viper.