Transition
快速简单的自定义过渡效果。
使用方法
要运行示例项目,只需运行 pod try transitional
。或者,您可以克隆仓库并在示例目录中运行项目。
默认过渡效果
- 滑动下
- 滑动上
- 从左侧翻动
- 从右侧翻动
- 放大
- 缩小
// Navigation Controller
transitionalPush(toVC, style: .SlideDown)
transitionalPop(.SideDown)
transitionalPopToRoot(.SlideUp)
transitionalPopToViewController(toVC, style: .SlideUp)
// Modal Presentation
transitionalPresentation(toVC, style: .SlideDown)
transitionalDismissal(.SlideUp)
自定义过渡效果
目前只有模态过渡支持自定义动画。推送/弹出支持即将推出!
fromVC.transitionalCustomDismissal(0.35) { transition in
// OR
fromVC.transitionalCustomPresentation(signInVC, duration: 0.35) { transition in
if let container = transition.containerView,
bottomVC = transition.bottomViewController,
topVC = transition.topViewController {
container.addSubview(bottomVC.view)
container.addSubview(topVC.view)
let originalFrame = bottomVC.view.frame
var endFrame = originalFrame
var startFrame = originalFrame
if transition.presenting {
startFrame.origin.y -= startFrame.size.height
} else {
endFrame.origin.y -= endFrame.size.height
}
topVC.view.frame = startFrame
UIView.animateWithDuration(transition.duration, animations: {
topVC.view.frame = endFrame
}) { _ in
topVC.view.frame = originalFrame
let cancelled = transition.completeTransition()
if cancelled {
transition.toViewController?.view.removeFromSuperview()
} else {
transition.fromViewController?.view.removeFromSuperview()
}
}
}
}
安装
通过CocoaPods可以获得Transitional。要安装它,只需在Podfile中添加以下行
pod "Transitional"
Swift版本
Transitional 0.2.0及以后版本需要Swift 4.2。对于旧版本的Swift,请使用Transitional 0.1.0构建版本。
文档
在此处阅读文档。
关于Transitional
Transitional是由@Imperiopolis创建的。
Transitional遵循MIT许可协议。有关详情,请参阅LICENSE文件。