From 16eefede24823c4280742ee9a61024b68b24ff52 Mon Sep 17 00:00:00 2001 From: Koji Murata Date: Wed, 26 Jul 2017 13:19:22 +0900 Subject: [PATCH] orientation animation only if supported --- Example/PictureInPicture/Info.plist | 1 - PictureInPicture/Classes/PictureInPictureWindow.swift | 6 ++++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Example/PictureInPicture/Info.plist b/Example/PictureInPicture/Info.plist index 6905cc6..73bcd8a 100644 --- a/Example/PictureInPicture/Info.plist +++ b/Example/PictureInPicture/Info.plist @@ -33,7 +33,6 @@ UISupportedInterfaceOrientations UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight diff --git a/PictureInPicture/Classes/PictureInPictureWindow.swift b/PictureInPicture/Classes/PictureInPictureWindow.swift index 315ce64..7becfbe 100644 --- a/PictureInPicture/Classes/PictureInPictureWindow.swift +++ b/PictureInPicture/Classes/PictureInPictureWindow.swift @@ -323,13 +323,15 @@ final class PictureInPictureWindow: UIWindow { } private func prepareNotifications() { - NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange), name: .UIDeviceOrientationDidChange, object: nil) + NotificationCenter.default.addObserver(self, selector: #selector(orientationDidChange), name: .UIApplicationDidChangeStatusBarOrientation, object: nil) NotificationCenter.default.addObserver(self, selector: #selector(willChangeStatusBarFrame(_:)), name: .UIApplicationWillChangeStatusBarFrame, object: nil) } @objc private func orientationDidChange() { if !isLargeState { - alpha = 0 + UIView.performWithoutAnimation { + self.alpha = 0 + } DispatchQueue.main.asyncAfter(deadline: .now() + 0.31) { self.alpha = 1 }