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?
Asked
Active
Viewed 1,239 times
1

GarySabo
- 5,806
- 5
- 49
- 124
-
Doesn't `\.displayScale` work for you? – Asperi Feb 18 '22 at 06:27
-
@Asperi I tried `displayScale` but on my iPhone 13 mini whether I am in standard or zoomed Display, they both return displayScale - 3.0? – GarySabo Feb 18 '22 at 20:29
1 Answers
7
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.