Auto layout is awesome right, but Apple's default way of writing Auto layout with code is too chicken ... Like a nightmare!
But as a hand (also) code (Love) Love (Pack) Good (X), with StoryBoard is obviously not our dish!
By the way, forget to say, Sizeclass is very cool, and is using IB to do, but don't worry, we should at least adapt to iOS7, that is, size class to very popular still have a period of time, then there must be big God (or you) find out the Size class code solution!
Let's go back to code writing Auto Layout.
The original is too troublesome to be discussed.
Two of the better packages I know are: masonry and pure layout. But look at Git,purelayout has not been updated for half a year! So, don't think about it. Let's introduce the use of masonry.
You can download the sample code from GitHub
Inside the Readme there is the installation process
Or you can look at me, too.
1. Writing Podfile
pod ‘Masonry‘
2. Enter the Podfile directory and install the pod install automatically
3. Define a macro in any global location (or any file, anyway, so you can use it)
#define MAS_SHORTHAND
4. Introduction of header Files
#import "Masonry.h"
Here, the configuration is complete
Write Auto layout--configuration by using masonry in pure code mode masonry