KTransition 1.0

KTransition 1.0

Kenan Atmaca 维护。




MIT Licance Pod Platform Tag Swift

需求

  • Xcode 9.0+
  • iOS 11.0 或更高版本

安装

CocoaPods

  1. 安装 CocoaPods
  2. 将此仓库添加到您的 Podfile
platform :ios, '11.0'

target 'ProjectName' do
  use_frameworks!
  pod 'KTransition'
end
  1. 运行 pod install
  2. 打开 CocoaPods 生成的新的 .xcworkspace 文件
  3. 在您想要使用库时:import KTransition

手动安装

  1. 只需下载 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文件获取详细信息。