if UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation) {
print("landscape")
}
if UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation){
print("portrait")
}
How can I check if it's landscape left or right?
you can do something 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 5
if UIDevice.current.orientation.isLandscape {
} else if UIDevice.current.orientation.isFlat {
} else if UIDevice.current.orientation.isPortrait {
} else if UIDevice.current.orientation.isValidInterfaceOrientation {
}
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 {
}