I\'ve just upgraded to XCode 4.5 GM and found out that you can now apply the \'4\" Retina\' size to your view controller in the storyboard.
Now if I want to create a
Add a 'New Swift File'-> AppDelegateEx.swift
add an extension to AppDelegate
import UIKit
extension AppDelegate {
class func isIPhone5 () -> Bool{
return max(UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height) == 568.0
}
class func isIPhone6 () -> Bool {
return max(UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height) == 667.0
}
class func isIPhone6Plus () -> Bool {
return max(UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height) == 736.0
}
}
usage:
if AppDelegate.isIPhone5() {
collectionViewTopConstraint.constant = 2
}else if AppDelegate.isIPhone6() {
collectionViewTopConstraint.constant = 20
}