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

Is it possible to switch to another view with a rotate animation? #130

Open
ergunkocak opened this issue Mar 28, 2017 · 7 comments
Open
Labels

Comments

@ergunkocak
Copy link

First of all tnx for such nice library :)

Is it possible to switch between custom views with a rotate (flip popup) animation?

Cheers

@ergunkocak
Copy link
Author

Kind a changeViewControllerWithAnimation

@ergunkocak
Copy link
Author

Hello again :)

I wrote this which is what i needed and putting here also if you want to add to the library.

extension PopupDialog {
    public func animateTo(_ vc: UIViewController) {
        if #available(iOS 9.0, *) {
            let stackView = popupContainerView.stackView as! UIStackView
            let vcToRemove = childViewControllers[0]
            addChildViewController(vc)
            viewController = vc
            viewController.didMove(toParentViewController: self)
            vcToRemove.removeFromParentViewController()

            UIView.transition(with: popupContainerView.stackView, duration: 0.1, options: [.beginFromCurrentState], animations: { _ in
                stackView.removeArrangedSubview(vcToRemove.view)
                stackView.addArrangedSubview(vc.view)
            })
            UIView.transition(with: popupContainerView, duration: 0.35, options: [.transitionFlipFromRight], animations: nil)
        } else {
            let stackView = popupContainerView.stackView as! TZStackView
            let vcToRemove = childViewControllers[0]
            addChildViewController(vc)
            viewController = vc
            viewController.didMove(toParentViewController: self)
            vcToRemove.removeFromParentViewController()

            UIView.transition(with: popupContainerView.stackView, duration: 0.1, options: [.beginFromCurrentState], animations: { _ in
                stackView.removeArrangedSubview(vcToRemove.view)
                stackView.addArrangedSubview(vc.view)
            })
            UIView.transition(with: popupContainerView, duration: 0.35, options: [.transitionFlipFromRight], animations: nil)
        }
    }
}

@mwfire
Copy link
Member

mwfire commented Mar 29, 2017

Thanks @ergunkocak, I will be looking into this very soonish 👍 🥇

@mwfire mwfire added the guide label Apr 16, 2017
@metisdev
Copy link

metisdev commented Dec 4, 2017

#177

@ergunkocak
Copy link
Author

@mwfire i made a pull request, fyi

@ergunkocak
Copy link
Author

Any updates on the merge?

@ergunkocak
Copy link
Author

@mwfire will this be merged at all? :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants