0

I want to find the value of UITraitEnvironmentLayoutDirection. It has the possible values of .leftToRight, .rightToLeft and .unspecified.

How do I use a switch (or some other statement) to detect which of these is the correct value?

I have tried the following:

switch UITraitEnvironmentLayoutDirection {
        case .leftToRight:
            print("left to right")
        case .rightToLeft:
            print("right to left")
        default:
            print("unknown")
    }

and it isn't valid syntax. So what is? How do I get the value?

  • 2
    You should be switching an instance of that enum. – Rakesha Shastri Oct 08 '18 at 17:38
  • @RakeshaShastri Can you please show me how to do that? I looked at enum and I still had no success. –  Oct 08 '18 at 17:39
  • Where are you using this piece of code? Show the rest of your code. – Rakesha Shastri Oct 08 '18 at 17:40
  • @RakeshaShastri I wish to get the screen's orientation. Instead of the print statements I will set it to something like "left" or "right". I don't see how any other code is necessary, please can you give me the enum statement to get the UITraitEnvironmentLayoutDirection? –  Oct 08 '18 at 17:42

0 Answers0