For example, set the background of iphone 5 to image1 and background of iphone 6 to image2, and a third different image for iphone 6+
How can I achieve this using Interface Builder
For example, set the background of iphone 5 to image1 and background of iphone 6 to image2, and a third different image for iphone 6+
How can I achieve this using Interface Builder
Programmatically you could do something like this (this assumes portrait only):
enum Device {
case iPhone5
case iPhone6
case iPhone6P
static var sizeClass: Device {
let screenWidth = UIScreen.mainScreen().bounds.width
switch screenWidth {
case _ where screenWidth < 375:
return .iPhone5
case 414:
return iPhone6P
default:
return .iPhone6
}
}
}
Then where you set the image:
switch Device.sizeClass {
case .iPhone5:
// set image
case .iPhone6:
// set image
case .iPhone6P:
// set image
}