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

Overview

SPM supported

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 Sources/DAExpandAnimation/DAExpandAnimation.swift file into your project.

Swift Package Manager

DAExpandAnimation is also available through Swift Package Manager. In Xcode select File > Swift Packages > Add Package Dependency... and type DAExpandAnimation in the search field.

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 - 2021 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.
You might also like...
Clocks made out of clocks made out of code

Clocks I came across this digital clock composed out of a set of analog clocks, created by Humans Since 1982, in a tweet, so I decided to remake it in

Contacts is an iOS app based on MVP (Model View Presenter) software architectural pattern.

Contacts Description Contacts is an iOS app based on MVP (Model View Presenter) software architectural pattern. Run Requirements Xcode 10.2.1 Swift 5.

Model View Presenter Framework written in Swift.
Model View Presenter Framework written in Swift.

BothamUI BothamUI is MVP (Model-View-Presenter) framework written in Swift. This project will help you setup all your presentation logic. BothamUI pro

SPLarkController - Custom transition between controllers. Settings controller for your iOS app.
SPLarkController - Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

Custom transition between controllers. Settings controller for your iOS app.
Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

iOS simple project to create half-screen modal view controller with pan
iOS simple project to create half-screen modal view controller with pan

Simple Half-screen view controller, draggable and less code (learning purpose)

A modal passcode input and validation view controller for iOS
A modal passcode input and validation view controller for iOS

TOPasscodeViewController A modal passcode input and validation view controller for iOS. TOPasscodeViewController is an open-source UIViewController su

BottomSheetDemo - Bottom sheet modal view controller with swift
BottomSheetDemo - Bottom sheet modal view controller with swift

当我们想弹出一个预览视图,bottom sheet modal view controller 非常实用。在 iOS 中,长按拖拽手势可以让 controlle

UIViewController extension to present view / view controller as bottom-half modal.
UIViewController extension to present view / view controller as bottom-half modal.

UIViewController extension to present view / view controller as bottom-half modal. Installation CocoaPods pod 'SemiModalViewController' Swift Package

A modal passcode input and validation view controller for iOS
A modal passcode input and validation view controller for iOS

TOPasscodeViewController A modal passcode input and validation view controller for iOS. TOPasscodeViewController is an open-source UIViewController su

Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle!
Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle!

iLabeledSeekSlider Custom & highly configurable seek slider with sliding intervals, disabled state and every possible setting to tackle! Minimum iOS v

A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI.
A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI.

📰 SwiftUI News App with NewsAPI A mobile application that presents the news received via NewsAPI to the user. Built with SwiftUI. ✅ Features The data

This app presents few examples for common patterns using purer SwiftUI code

VIPERtoSwiftUI GOAL This app presents few examples for common patterns using purer (from authors experience) SwiftUI code. LITERATURE https://www.appy

A peer to peer framework for OS X, iOS and watchOS 2 that presents a similar interface to the MultipeerConnectivity framework

This repository is a peer to peer framework for OS X, iOS and watchOS 2 that presents a similar interface to the MultipeerConnectivity framework (which is iOS only) that lets you connect any 2 devices from any platform. This framework works with peer to peer networks like bluetooth and ad hoc wifi networks when available it also falls back onto using a wifi router when necessary. It is built on top of CFNetwork and NSNetService. It uses the newest Swift 2's features like error handling and protocol extensions.

Appstore card animation transition. UICollectionView and UITableView card expand animated transition
Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

Page view controller with bounce effect
Page view controller with bounce effect

BouncyPageViewController Page view controller with bounce effect inspired by motion design by Stan Yakushevish. Quickstart Create a queue of UIViewCon

This component implements transition animation to crumble view-controller into tiny pieces.
This component implements transition animation to crumble view-controller into tiny pieces.

StarWars Animation This component implements transition animation to crumble view-controller into tiny pieces. Check this project on dribbble. Also, r

Custom-TopBarController - A Custom TopBar Controller With Swift
Custom-TopBarController - A Custom TopBar Controller With Swift

TopBarController Верстка Для IPhone и IPod вертска адаптивная, для IPad frane To

Comments
  • Expand animation in tab bar controller

    Expand animation in tab bar controller

    Hi, I downloaded the demo project and am trying to do the expand transition inside a tab bar controller, such that the tab bar keeps unchanged (the transition would happen behind the tab bar basically). Not succeeding so far. Tried among other things to create a container view inside the tab, which embeds the table view controller, which has the modal segue to the expanded view controller... the tab bar always hides. Any idea? Thanks!

    opened by ivanschuetz 3
  • Remove @objc conformance and refactor optional protocol methods to default implementations in protocol extensions.

    Remove @objc conformance and refactor optional protocol methods to default implementations in protocol extensions.

    Remove @objc conformance and refactor optional protocol methods to default implementations in protocol extensions. Useful if you want to create a protocol ExpandingUserInterface and a protocol extension with default implementations for all expandable ViewControllers (e.g. extension ExpandingUserInterface where Self: UIViewController). You can then implement default implementations for only those animation adapter methods that you need while leaving the rest as defined in the default implementations of DAExpandAnimation (no ops...).

    opened by fe9lix 1
  • Navigation Bar/pushViewController

    Navigation Bar/pushViewController

    I really love this animation but I need to use it with a navigation controller. The problem I'm having is that to add the toViewController to the navigation stack I need to use the pushViewController method instead of just presenting the new View Controller (i.e. presentViewController).

    Do you have any advice on how to do this? I apologize if I sound amateurish, I'm relatively new to iOS development but I fully understand Swift and View Controllers and the Navigation Stack, I'm just struggling with the animation and how to use it for my project.

    opened by SikandAlex 2
  • Set frontView frame in expanding animation *after* calling prepareExpandingView.

    Set frontView frame in expanding animation *after* calling prepareExpandingView.

    Set frontView frame in expanding animation after calling prepareExpandingView (animation adapter might want to work with the original frame, for instance for creating a snapshot view...).

    opened by fe9lix 1
Owner
Denis Avdeev
Denis Avdeev
LiteRoute is easy transition for your app. Written on Swift 4

LiteRoute Description LiteRoute is easy transition between VIPER modules, who implemented on pure Swift. We can transition between your modules very e

Vladislav Prusakov 90 Mar 12, 2021
A demonstration to the approach of leaving view transition management to a router.

SwiftUI-RouterDemo This is a simplified demonstration to the approach of leaving view transition management to a router.

Elvis Shi 3 May 26, 2021
🍞 [Beta] A view controller that can unwind like presentation and navigation.

FluidPresentation - no more handling presented or pushed in view controller A view controller that supports the interactive dismissal by edge pan gest

Muukii 19 Dec 22, 2021
Crossroad is an URL router focused on handling Custom URL Scheme

Crossroad is an URL router focused on handling Custom URL Scheme. Using this, you can route multiple URL schemes and fetch arguments and parameters easily.

Kohki Miki 331 May 23, 2021
Provides a custom presentation modifier that provides more options including full screen presentations. (iOS)

Presentation Also available as a part of my SwiftUI+ Collection – just add it to Xcode 13+ Provides a custom presentation modifier that provides more

SwiftUI+ 15 Dec 3, 2022
A custom modal transition that presents and dismiss a controller with an expanding bubble effect.

A custom modal transition that presents and dismiss a controller inside an expanding and shrinking bubble. Screenshot Usage Install through CocoaPods:

Andrea Mazzini 3.3k Dec 28, 2022
Custom-Transition - A repo about custom transition between two view controllers

Custom-Transition in SWIFT This is a repo about custom transition between two vi

Prakash Chandra Awal 0 Jan 6, 2022
A UIKit custom modal transition that simulates an elastic drag

A UIKit custom transition that simulates an elastic drag.This is the Objective-C Version of Elastic Transition written in Swift by lkzhao

Matteo Tagliafico 397 Oct 28, 2022
MMPlayerView - Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

MMPlayerView Demo-Swift List / Shrink / Transition / Landscape MMPlayerLayer ex. use when change player view frequently like tableView / collectionVie

Millman Yang 724 Nov 24, 2022
📃 FoldingCell is an expanding content cell with animation made by @Ramotion

FOLDING CELL Expanding content cell with animation inspired by folding paper card material design. We specialize in the designing and coding of custom

Ramotion 10.1k Jan 2, 2023