Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SwiftUI: Detect Display Zoom is on?

This question has been asked before but none of the solutions work. I can't believe that in SwiftUI, similar to @Environment(\.sizeCategory) var sizeCategory there isn't a similar environment variable that we can observe and switch on?

like image 745
GarySabo Avatar asked Nov 01 '25 01:11

GarySabo


1 Answers

This was working for me (from that other post you referenced):

private var isZoomed: Bool {
    UIScreen.main.scale < UIScreen.main.nativeScale
}

I am also using this to determine if bold is toggled on in the accessibility settings.

@Environment(\.legibilityWeight)
private var legibilityWeight

with a combination of the text size:

@Environment(\.sizeCategory)
private var sizeCategory

I adjust the UI when it becomes too narrow and text too big to fit the text I want.

like image 146
Jeff Mark Avatar answered Nov 03 '25 16:11

Jeff Mark



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!