Alternative to Auto-layout
For Swift Developers who are control freaks and want to paint UIElements by code, there is an alternative to Auto-Layout. By finding the percentage of the UIElement (as well as spacing) to the whole screen, we can create a UIView that will scale down based on the device’s screen. For example; on an iPhone6 device, my headerView and footerView and 20% of the whole screen, and the bodyView is the remainder of the screen. I can go with: var x : CGFloat = 0 var y : CGFloat = 0 var w : CGFloat = view.bounds.width var h : CGFloat = view.bounds.height * 0.20  // <-- 20% of my device’s height var headerView = CGRectMake(x,y,w,h) Test the headerView in all the devices and it will show you that it has occupied 20% of the view’s height.












