View2ViewTransition:简单的框架实现两个视图切换及转场

网友投稿 549 2022-10-31

View2ViewTransition:简单的框架实现两个视图切换及转场

View2ViewTransition:简单的框架实现两个视图切换及转场

View2ViewTransition

Simple framework for custom interactive viewController transition from one view to another view.

Installation

Carthage

github "naru-jpn/View2ViewTransition"

CocoaPods

pod 'View2ViewTransition'

Usage

Create TransitionController and implement presentation

// Create TransitionControllervar transitionController: TransitionController = TransitionController()

// Present view controller with transition delegatelet presentedViewController: PresentedViewController = PresentedViewController()presentedViewController.transitioningDelegate = transitionControllertransitionController.present(viewController: presentedViewController, on: self, attached: presentedViewController, completion: nil)

(also supports push)

// Set transitionController as a navigation controller delegate and push.let presentedViewController: PresentedViewController = PresentedViewController()if let navigationController = self.navigationController { navigationController.delegate = transitionController transitionController.push(viewController: presentedViewController, on: self, attached: presentedViewController)}

Presenting viewController conforms View2ViewTransitionPresenting

func initialFrame(userInfo: [String: AnyObject]?, isPresenting: Bool) -> CGRectfunc initialView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> UIViewfunc prepereInitialView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> Void // (optional)

Presented viewController conforms View2ViewTransitionPresented

func destinationFrame(userInfo: [String: AnyObject]?, isPresenting: Bool) -> CGRectfunc destinationView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> UIViewfunc prepareDestinationView(userInfo: [String: AnyObject]?, isPresenting: Bool) -> Void // (optional)

Use UserInfo

You can set userInfo to notify indexPath or share resource etc.

transitionController.userInfo = ["key": "value", ...]

Modify Animation Parameters

Animate with custom animation parameters.

// For presenttransitionController.presentAnimationController.usingSpringWithDamping = 0.7transitionController.presentAnimationController.initialSpringVelocity = 0.0transitionController.presentAnimationController.animationOptions = [.CurveEaseInOut]// For dismisstransitionController.dismissAnimationController.usingSpringWithDamping = 0.7transitionController.dismissAnimationController.initialSpringVelocity = 0.0transitionController.dismissAnimationController.animationOptions = [.CurveEaseInOut]

Debug Mode

If you have hierarchical view controllers (navigation controllers) in app, viewController to conform protocol is not intuitive. View2ViewTransition prints some information in debug mode.

let transitionController = TransitionController()// ...transitionController.debuging = true

Example

View2ViewTransitionExample

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Foundation:目前世界上最先进的前端响应式框架
下一篇:spring2
相关文章

 发表评论

暂时没有评论,来抢沙发吧~