Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the background view origin when presenting #183

Merged
merged 2 commits into from
Sep 25, 2020

Conversation

kenzinn
Copy link
Contributor

@kenzinn kenzinn commented Aug 14, 2020

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.

Checklist

Motivation and Context

The issue this fixes is described in Issue #181 .

Before this fix, the frame of the presenting VC's View is being applied to the background view during the transition animation. However, the frame of the presenting VC's View is always going to have an origin of (x: 0, y: 0) in it's own coordinate system.

If the presenting VC is not actually at the origin of the screen (which will also be the origin of the transition's containerView), then the background will be the same size as the presenting VC but located at the origin, not correctly aligned with the presenting VC.

I've tested this inside a project in a couple of different presenting VC scenarios.

If the old behavior is preferred by the maintainers, no problem. Thanks for sharing this useful library.

Description

This PR fixes that problem by converting the frame into the containerView's coordinate system before applying it to the background view.

Mostly just this: let fromFrame = containerView.convert(fromView.frame, from: fromView)

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.**
@alexisakers
Copy link
Owner

This is looking great, thanks for looking into it.

@alexisakers alexisakers merged commit 40155be into alexisakers:develop Sep 25, 2020
alexisakers added a commit that referenced this pull request Oct 26, 2020
* Fix the background view origin when presenting (#183)

* 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

* Add support for Swift Package Manager (#158) (#178)

* Update project to support Swift Package Manager

* Update CHANGELOG

* Only create one library

* Reorganize Swift project to better support SPM

* Update README

* Clean up files

* Update BLTNItem.swift

* Rename master to main

* Update Podscpec

* Require iOS 11

* Update CHANGELOG

* Update podspec

* SPM also to require iOS 11 (#190)

As outlined by version 5 manifest.

Co-authored-by: Ken Zinn <ken.zinn@nonzerosolutions.com>
Co-authored-by: Olli Tapaninen <ollitapa@gmail.com>
alexisakers added a commit that referenced this pull request Oct 26, 2020
* Fix the background view origin when presenting (#183)

* 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

* Add support for Swift Package Manager (#158) (#178)

* Update project to support Swift Package Manager

* Update CHANGELOG

* Only create one library

* Reorganize Swift project to better support SPM

* Update README

* Clean up files

* Update BLTNItem.swift

* Rename master to main

* Update Podscpec

* Require iOS 11

* Update CHANGELOG

* Update podspec

* SPM also to require iOS 11 (#190)

As outlined by version 5 manifest.

Co-authored-by: Ken Zinn <ken.zinn@nonzerosolutions.com>
Co-authored-by: Olli Tapaninen <ollitapa@gmail.com>

Co-authored-by: Ken Zinn <ken.zinn@nonzerosolutions.com>
Co-authored-by: Olli Tapaninen <ollitapa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants