Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

swift 3 check if iphone 6/7 and 6/7plus display is in standard or zoomed mode

Tags:

ios

swift

iphone

I wonder how I can check if the user has the display set to zoomed mode.

I have tried this:

public var isZoomed: Bool {
    return UIScreen.main().scale < UIScreen.main().nativeScale
}

And also:

#define IS_OS_8_OR_LATER    ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_IPHONE_5 (IS_IPHONE && ([[UIScreen mainScreen] bounds].size.height == 568.0) && ((IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale) || !IS_OS_8_OR_LATER))
#define IS_STANDARD_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0  && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale == [UIScreen mainScreen].scale)
#define IS_ZOOMED_IPHONE_6 (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 568.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale > [UIScreen mainScreen].scale)
#define IS_STANDARD_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 736.0)
#define IS_ZOOMED_IPHONE_6_PLUS (IS_IPHONE && [[UIScreen mainScreen] bounds].size.height == 667.0 && IS_OS_8_OR_LATER && [UIScreen mainScreen].nativeScale < [UIScreen mainScreen].scale)

But I none of them works.

So is there a way to detect if the device is zoomed or even force it to not be zoomed when the app is running?

like image 579
user2636197 Avatar asked Nov 29 '16 11:11

user2636197


People also ask

Does iPhone 6 have display zoom?

You can see larger onscreen controls on an iPhone with Display Zoom. Go to Settings > Display & Brightness > Display Zoom. Select Larger Text to make all the text on iPhone larger. Tap Done, then tap Use Zoomed.

What is the difference between standard and zoomed in iPhone?

What Apple does, when you select “Zoomed,” is they treat your iPhone as if it's a different model— one with a smaller screen, and fewer pixels. If you take the image that would have fit on a smaller screen, but you stretch it to fit a larger screen, everything is bigger. And that's how Zoomed works.

Is zoomed display better iPhone?

The main advantage of Display Zoom is that it applies to the entire screen evenly, enlarging everything uniformly. Unlike Dynamic Text, there is no distortion of the relative size of interface elements. Text is easier to read, UI elements are easier to touch. This latter point is frequently the more useful aspect.


1 Answers

Working swift 3 solution:

if (UIScreen.main.bounds.size.height == 667.0 && UIScreen.main.nativeScale < UIScreen.main.scale) {
    print("iphone 6 plus")
} else {
    print("none zoomed 6 plus")
}
        
if (UIScreen.main.bounds.size.height == 568.0 && UIScreen.main.nativeScale > UIScreen.main.scale) {
    print("zoomed iphone 6")
} else {
    print("none zoomed")
}
like image 51
user2636197 Avatar answered Sep 18 '22 12:09

user2636197