Skip to content

Commit

Permalink
orientation animation only if supported
Browse files Browse the repository at this point in the history
  • Loading branch information
Koji Murata committed Jul 26, 2017
1 parent 390cc8a commit 16eefed
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 0 additions & 1 deletion Example/PictureInPicture/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
Expand Down
6 changes: 4 additions & 2 deletions PictureInPicture/Classes/PictureInPictureWindow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 16eefed

Please sign in to comment.