1

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?

GarySabo
  • 5,806
  • 5
  • 49
  • 124

1 Answers1

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.

RanLearns
  • 4,086
  • 5
  • 44
  • 81
Jeff Mark
  • 111
  • 1
  • 4