Developing same UI for 3.5, 4.0 (updated 4.7 and 5.5) inches screens in Xcode 5.0.1 (updated xcode 6), no landscape, no iPad and no storyboard

后端 未结 5 770
生来不讨喜
生来不讨喜 2020-12-23 12:37
  1. I have developed app considering 3.5 inch with .xib files and not storyboard.
  2. I am unable to find any tutorial or guide which will help me in designing app si
5条回答
  •  情话喂你
    2020-12-23 13:22

    Put below lines in prefix.pch

    #define IS_DEVICE_RUNNING_IOS_7_AND_ABOVE() ([[[UIDevice currentDevice] systemVersion] compare:@"7.0" options:NSNumericSearch] != NSOrderedAscending)
    #define iPhoneVersion ([[UIScreen mainScreen] bounds].size.height == 568 ? 5 : ([[UIScreen mainScreen] bounds].size.height == 480 ? 4 : ([[UIScreen mainScreen] bounds].size.height == 667 ? 6 : ([[UIScreen mainScreen] bounds].size.height == 736 ? 61 : 999))))
    

    Now in programming you can say...

    if (IS_DEVICE_RUNNING_IOS_7_AND_ABOVE()) {
        NSLog("This is iOS 7");
    } else {
        NSLog("This is iOS 6 or below");
    }
    
    
    if (iPhoneVersion==4) {
        NSLog("This is 3.5 inch iPhone - iPhone 4s or below");
    } else if (iPhoneVersion==5) {
        NSLog("This is 4 inch iPhone - iPhone 5 family");
    } else if (iPhoneVersion==6) {
        NSLog("This is 4.7 inch iPhone - iPhone 6");
    } else if (iPhoneVersion==61) {
        NSLog("This is 5.5 inch iPhone - iPhone 6 Plus.. The BIGGER");
    } else {
        NSLog("This is iPad");
    }
    

提交回复
热议问题