DAExpandAnimation

A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants.

Github stars Tracking Chart

DAExpandAnimation

A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants.

Screenshot

DAExpandAnimation

Installation

Simply copy the Xpandr/DAExpandAnimation.swift file into your project.

Usage

Try the example project!

Have your view controller conform to UIViewControllerTransitioningDelegate. Optionally set the collapsedViewFrame, the expandedViewFrame and the animationDuration.

private let animationController = DAExpandAnimation()

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
    let toViewController = segue.destination
    
    if let selectedCell = sender as? UITableViewCell {
        toViewController.transitioningDelegate = self
        toViewController.modalPresentationStyle = .custom
        toViewController.view.backgroundColor = selectedCell.backgroundColor
        
        animationController.collapsedViewFrame = {
            return selectedCell.frame
        }
        animationController.animationDuration = Constants.someAnimationDuration
        
        if let indexPath = tableView.indexPath(for: selectedCell) {
            tableView.deselectRow(at: indexPath, animated: false)
        }
    }
}
    
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return animationController
}

func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
    return animationController
}

Protocols

Adopting DAExpandAnimationPresentingViewAdapter provides the following optional delegate methods for tailoring the presenter's UX.

/// A boolean value that determines whether the animations include sliding
/// the presenting view apart. Defaults to `true`.
var shouldSlideApart: Bool { get }

/// Notifies the presenting view adapter that animations are about to occur.
func animationsWillBegin(in view: UIView, presenting isPresentation: Bool)

/// Notifies the presenting view adapter that animations are just completed.
func animationsDidEnd(presenting isPresentation: Bool)

Adopting DAExpandAnimationPresentedViewAdapter provides the following optional delegate methods for tailoring the presentation of a new view controller.

/// Gives the presented view adapter a chance to prepare
/// the expanding `view` before the animations.
func prepare(expanding view: UIView)

/// Gives the presented view adapter ability to change
/// properties of the expanding `view` alongside the animations.
func animate(expanding view: UIView)

/// Gives the presented view adapter ability to clean the expanded `view` up
/// after the animations are performed.
func cleanup(expanding view: UIView)

/// Gives the presented view adapter a chance to prepare
/// the collapsing `view` before the animations.
func prepare(collapsing view: UIView)

/// Gives the presented view adapter ability to change
/// properties of the collapsing `view` alongside the animations.
func animate(collapsing view: UIView)

/// Gives the presented view adapter ability to clean the collapsed `view`
/// up after the animations are performed.
func cleanup(collapsing view: UIView)

#MIT License

Copyright (c) 2015 - 2017 Denis Avdeev. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Main metrics

Overview
Name With Ownerifitdoesntwork/DAExpandAnimation
Primary LanguageSwift
Program languageSwift (Language Count: 1)
Platform
License:MIT License
所有者活动
Created At2015-09-03 19:14:16
Pushed At2025-02-01 19:45:58
Last Commit At2025-02-02 00:44:34
Release Count4
Last Release Name1.2.0 (Posted on 2025-02-02 00:45:49)
First Release Name1.0.0 (Posted on 2020-04-18 19:46:41)
用户参与
Stargazers Count581
Watchers Count14
Fork Count44
Commits Count49
Has Issues Enabled
Issues Count4
Issue Open Count1
Pull Requests Count4
Pull Requests Open Count2
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private