用接口方向替换设备方向

Cod*_*221 3 xcode ios swift

我一直在用它来改变方向

  if (UIDevice.current.orientation == UIDeviceOrientation.portrait)
Run Code Online (Sandbox Code Playgroud)

如何用UIInterfaceOrientation.portrait以上语法替换它。这是因为UIDeviceOreientationhas faceupfacedown对我没有用。

tru*_*duc 7

您可以将其替换为下面的行

if (UIApplication.shared.statusBarOrientation == UIInterfaceOrientation.portrait)
Run Code Online (Sandbox Code Playgroud)