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
In Swift, iOS 8+ project I like to make an extension on UIScreen
, like:
extension UIScreen {
var isPhone4: Bool {
return self.nativeBounds.size.height == 960;
}
var isPhone5: Bool {
return self.nativeBounds.size.height == 1136;
}
var isPhone6: Bool {
return self.nativeBounds.size.height == 1334;
}
var isPhone6Plus: Bool {
return self.nativeBounds.size.height == 2208;
}
}
(NOTE: nativeBounds
is in pixels).
And then the code will be like:
if UIScreen.mainScreen().isPhone4 {
// do smth on the smallest screen
}
So the code makes it clear that this is a check for the main screen, not for the device model.