Open Xcode and create a new Single View Application. For product name, use DifferentiateIphoneSize and then fill out the Organization Name and Company Identifier with your customary values. Select iPhone for Devices.
For demonstration purposes, add a label inside the view controller and change the text to "3.5-inch or 4-inch".
Build and Run, a label can be seen with text "iPhone retina-4 inch" if the app is run in with 4-inch size, otherwise "iPhone retina-3.5 inch".
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
if ([[UIScreen mainScreen] scale] == 2.0) {
if([UIScreen mainScreen].bounds.size.height == 568){
// iPhone retina-4 inch
self.lbl_textOutput.text = @"iPhone retina-4 inch";
} else{
// iPhone retina-3.5 inch
self.lbl_textOutput.text = @"iPhone retina-3.5 inch";
}
}
else {
// not retina display
self.lbl_textOutput.text = @"iPhone that's not retina display";
}
}
You can download the source code of the DifferentiateIphoneSize at my repository on bitbucket.
0 nhận xét:
Đăng nhận xét