Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ifitdoesntwork/daexpandanimation
A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants.
https://github.com/ifitdoesntwork/daexpandanimation
animation ios swift6 transition uikit
Last synced: 1 day ago
JSON representation
A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants.
- Host: GitHub
- URL: https://github.com/ifitdoesntwork/daexpandanimation
- Owner: ifitdoesntwork
- License: mit
- Created: 2015-09-03T19:14:16.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-02-01T19:45:58.000Z (9 days ago)
- Last Synced: 2025-02-03T04:04:27.547Z (8 days ago)
- Topics: animation, ios, swift6, transition, uikit
- Language: Swift
- Homepage:
- Size: 2.49 MB
- Stars: 581
- Watchers: 14
- Forks: 44
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[![SPM supported](https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg)](https://swift.org/package-manager)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fifitdoesntwork%2FDAExpandAnimation%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/ifitdoesntwork/DAExpandAnimation)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fifitdoesntwork%2FDAExpandAnimation%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/ifitdoesntwork/DAExpandAnimation)
# DAExpandAnimation
A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants.
# Screenshot
![DAExpandAnimation](https://raw.githubusercontent.com/ifitdoesntwork/DAExpandAnimation/master/Example/screencapture.gif)
# Installation
Simply copy the `Sources/DAExpandAnimation/DAExpandAnimation.swift` file into your project.
### Swift Package Manager
DAExpandAnimation is also available through [Swift Package Manager](https://github.com/apple/swift-package-manager/).
```swift
.package(url: "https://github.com/ifitdoesntwork/DAExpandAnimation.git", from: "1.0.0")
```
# Usage
Try the example project!Have your view controller conform to UIViewControllerTransitioningDelegate. Optionally set the `collapsedViewFrame`, the `expandedViewFrame`, the `slidingPart` and the `animationDuration`.
```swift
private let animationController = DAExpandAnimation()override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
guard let selectedCell = sender as? UITableViewCell else {
return
}
let toViewController = segue.destination
toViewController.transitioningDelegate = self
toViewController.modalPresentationStyle = .custom
toViewController.view.backgroundColor = selectedCell.backgroundColor
animationController.collapsedViewFrame = {
selectedCell.frame
}
animationController.animationDuration = Constants.demoAnimationDuration()
}
func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
animationController
}func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
animationController
}
```
# ProtocolsAdopting `DAExpandAnimationPresentingViewAdapter` provides the following optional delegate methods for tailoring the presenter's UX.
```swift
/// Determines whether the animations include sliding the presenter's view apart.
/// Defaults to `true`.
var shouldSlideApart: Bool { get }/// Notifies the presenter's view adapter that animations are about to occur.
func animationsWillBegin(in view: UIView, presenting isPresentation: Bool)/// Notifies the presenter's 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.```swift
/// 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)
```