Skip to content

Commit

Permalink
Fix the background view origin when presenting (#183)
Browse files Browse the repository at this point in the history
* Fix the background view origin when presenting

When presenting over a ViewController (the “from” VC), if that ViewController is not at the screen’s origin, the background view will not appear at the correct position above it.

This fixes the problem by setting the background view’s frame to the “from” VC’s view’s frame **converted into the coordinate system of the container view.**

* add PR to CHANGELOG
  • Loading branch information
kenzinn committed Sep 25, 2020
1 parent 5c28acb commit 40155be
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# _BulletinBoard_ Changelog
## Unreleased
### Fixes
- Fix the background view origin when presenting
[#183](https://github.com/alexaubry/BulletinBoard/pull/183)

## 🔖 v4.1.2
### Fixes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,18 @@ class BulletinPresentationAnimationController: NSObject, UIViewControllerAnimate
return
}

let containerView = transitionContext.containerView

// Fix the frame (Needed for iPad app running in split view)
if let fromFrame = transitionContext.viewController(forKey: .from)?.view.frame {
// (Convert the "from" view's frame coordinates to the container view's coordinate system)
if let fromView = transitionContext.viewController(forKey: .from)?.view {
let fromFrame = containerView.convert(fromView.frame, from: fromView)
toVC.view.frame = fromFrame
}

let rootView = toVC.view!
let contentView = toVC.contentView
let backgroundView = toVC.backgroundView!
let containerView = transitionContext.containerView

// Add root view

Expand Down

0 comments on commit 40155be

Please sign in to comment.