Skip to content
프로젝트

소개

프레젠터의 잔여 화면을 밀어내면서 컨트롤러를 확장 효과로 표시하는 사용자 지정 모달 전환입니다.

웹 및 앱 개발

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

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.

.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.

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
}

Protocols

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

/// 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.

/// 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)

관련 프로젝트 살펴보기

불러오는 중…