Skip to content

Adding CSCardTransitionProperties

Latest
Compare
Choose a tag to compare
@jeanhbr jeanhbr released this 01 Sep 13:11

You can now use CSCardTransitionProperties to customize your transition easily and debug it.

Customize your transition

You can customize all of the properties below simply by providing a custom instance of CSCardTransitionProperties to the Presented View Controller. For instance:

extension YourViewController: CSCardPresentedView {
	var cardTransitionProperties: CSCardTransitionProperties { 
		return CSCardTransitionProperties(
			/// Presenting animation properties
			presentPositioningDuration: TimeInterval, 
			presentResizingDuration: TimeInterval, 
			presentStatusStyleUpdateDuration: TimeInterval, 
			/// Dismissing animation properties
			dismissPositioningDuration: TimeInterval, 
			dismissResizingDuration: TimeInterval, 
			dismissBlurDuration: TimeInterval, 
			dismissStatusStyleUpdateDuration: TimeInterval, 
			/// Fade transition duration between presented card view and presenter card view
			dismissFadeCardAnimationTime: TimeInterval, 
			/// How far should the user swipe to dismiss the view
			preDismissingTransitionProgressPortion: CGFloat, 
			/// Cancel animation duration
			cancelTransitionResizingDuration: TimeInterval, 
			/// Blurred background color during transition
			transitionBackgroundColor: UIColor
		)
	}
}

Note: all of these properties have default values, so you can skip the ones you don't want to change in the instance creation.

Debug your transition

The transition must be quick in production, but slow it down (to 1/10) during its development so you can easily see what is working and what still needs some improvements. You can enable debug mode by simply providing a debug instance of the CSCardTransitionProperties to the Presented View Controller.

extension YourViewController: CSCardPresentedView {
	var cardTransitionProperties: CSCardTransitionProperties { 
		return .debug
	}
}