需求
- Xcode 9.0+
- iOS 11.0 或更高版本
安装
CocoaPods
- 安装 CocoaPods
- 将此仓库添加到您的
Podfile
platform :ios, '11.0'
target 'ProjectName' do
use_frameworks!
pod 'KTransition'
end
- 运行
pod install
- 打开 CocoaPods 生成的新的
.xcworkspace
文件 - 在您想要使用库时:
import KTransition
手动安装
- 只需下载
KTransition
的源文件并将它们导入您的项目。
使用方法
- 导航推送与弹出
self.navigationController?.customPushTransition = KTransition.push(style: .top, duration: 0.5)
- 视图控制器显示与隐藏
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OtherVC") as! OtherVC
vc.customPresentTransition = KTransition.present(style: .scale, duration: 0.5, startFrame: nil)
self.present(vc, animated: true, completion: nil)
- 触摸开始位置的动画
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
let touch = touches.first!
let location = touch.location(in: self.view)
let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "OtherVC") as! OtherVC
vc.customPresentTransition = KTransition.present(style: .bounds, duration: 0.5, startFrame: location)
self.present(vc, animated: true, completion: nil)
}
动画样式
- 透明度
- 缩放
- 顶部
- 左侧
- 边界
许可
在MIT 许可证下提供使用。查看LICENSE文件获取详细信息。