ios - How to check if device orientation is landscape left or right in swift? -
if uideviceorientationislandscape(uidevice.currentdevice().orientation) { print("landscape") } if uideviceorientationisportrait(uidevice.currentdevice().orientation){ print("portrait") }
how can check if it's landscape left or right?
you can like,
if uidevice.currentdevice().orientation == uideviceorientation.landscapeleft{ } else if uidevice.currentdevice().orientation == uideviceorientation.landscaperight{ } else if uidevice.currentdevice().orientation == uideviceorientation.uideviceorientationportraitupsidedown{ } else if uidevice.currentdevice().orientation == uideviceorientation.uideviceorientationportrait{ }
swift 3
if uidevice.current.orientation == uideviceorientation.landscapeleft { } else if uidevice.current.orientation == uideviceorientation.landscaperight { } else if uidevice.current.orientation == uideviceorientation.portrait { } else if uidevice.current.orientation == uideviceorientation.portraitupsidedown { }
Comments
Post a Comment