From e8272e3bc2b9ec298b01ab2d9908b6b5fcba4221 Mon Sep 17 00:00:00 2001 From: Petri Tilli Date: Thu, 14 May 2020 18:13:07 +0300 Subject: [PATCH] Fix for iPad split view bug (#173) * Fixed the iPad animation bug when bulletin shown, also couple deprecation warnings * Updated Changelog * Corrected the available -check --- CHANGELOG.md | 5 +++++ .../Animations/BulletinDismissAnimationController.swift | 6 +++++- .../BulletinPresentationAnimationController.swift | 5 +++++ Sources/Support/BulletinViewController.swift | 6 +++++- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8ef64f..25a7e9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ - Remove testing dependencies from the Cartfile [#166](https://github.com/alexaubry/BulletinBoard/pull/166) +## Unreleased +### Fixes +- Fix for iPad split view bug +[#173] (https://github.com/alexaubry/BulletinBoard/pull/173) + ## 🔖 v4.0.0 ### Fixes - Upgrade to Swift 5 diff --git a/Sources/Support/Animations/BulletinDismissAnimationController.swift b/Sources/Support/Animations/BulletinDismissAnimationController.swift index 6955f5e..24a6193 100644 --- a/Sources/Support/Animations/BulletinDismissAnimationController.swift +++ b/Sources/Support/Animations/BulletinDismissAnimationController.swift @@ -42,7 +42,11 @@ class BulletinDismissAnimationController: NSObject, UIViewControllerAnimatedTran snapshotActivityIndicator.rightAnchor.constraint(equalTo: snapshot.rightAnchor).isActive = true snapshotActivityIndicator.bottomAnchor.constraint(equalTo: snapshot.bottomAnchor).isActive = true - snapshotActivityIndicator.style = .whiteLarge + if #available(iOS 13.0, *) { + snapshotActivityIndicator.style = UIActivityIndicatorView.Style.large + } else { + snapshotActivityIndicator.style = .whiteLarge + } snapshotActivityIndicator.color = .black snapshotActivityIndicator.isUserInteractionEnabled = false diff --git a/Sources/Support/Animations/BulletinPresentationAnimationController.swift b/Sources/Support/Animations/BulletinPresentationAnimationController.swift index 671ad15..2eaf3ee 100644 --- a/Sources/Support/Animations/BulletinPresentationAnimationController.swift +++ b/Sources/Support/Animations/BulletinPresentationAnimationController.swift @@ -31,6 +31,11 @@ class BulletinPresentationAnimationController: NSObject, UIViewControllerAnimate return } + // Fix the frame (Needed for iPad app running in split view) + if let fromFrame = transitionContext.viewController(forKey: .from)?.view.frame { + toVC.view.frame = fromFrame + } + let rootView = toVC.view! let contentView = toVC.contentView let backgroundView = toVC.backgroundView! diff --git a/Sources/Support/BulletinViewController.swift b/Sources/Support/BulletinViewController.swift index f05e6d2..054a953 100644 --- a/Sources/Support/BulletinViewController.swift +++ b/Sources/Support/BulletinViewController.swift @@ -165,7 +165,11 @@ extension BulletinViewController { activityIndicator.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true activityIndicator.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true - activityIndicator.style = .whiteLarge + if #available(iOS 13.0, *) { + activityIndicator.style = UIActivityIndicatorView.Style.large + } else { + activityIndicator.style = .whiteLarge + } activityIndicator.color = .black activityIndicator.isUserInteractionEnabled = false