登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

AZTransitions

[复制链接]
来自: Torr 分类: iOS精品源码 上传时间: 2017-1-3 10:37:06

项目介绍:

AZTransitions

https://github.com/azimin/AZTransitions

Make your modal transition with custom animation.
AZTransitions helps you think about creativity, giving specific API methods.

AZTransitions 使用自定义动画进行模态转换。提供具体的API方法。

Visual Example

Animation example

Installation

  • Add the following to your Podfile and run pod install

pod 'AZTransitions'
  • or add the following to your Cartfile and run carthage update

github "azimin/AZTransitions"
  • or clone as a git submodule,

  • or just copy AZTransitions/Source/CustomModalTransition.swift into your project.

Code Example

To create any custom transition just subclass CustomModalTransition:

class FashionTransition: CustomModalTransition { 
  override init() {
    super.init(duration: 0.5)
  }
}

--

Then set as az_modalTransition to nessesary view just before presenting it

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  segue.destination.customModalTransition = FashionTransition()
}

or

func show() {
  let viewController = UIViewController()
  viewController.az_modalTransition = FashionTransition()
  self.present(viewController, animated: true, completion: nil)
}

--

To have custom present animation, just implement performTransition(interactive: Bool) inside your FashionTransition class:

func performTransition(interactive: Bool) {
  self.presentedViewController.view.alpha = 0.0
    
  UIView.animate(withDuration: duration, animations: {
    self.presentedViewController.view.alpha = 1.0
    self.presentingViewController.view.alpha = 0.0
  }, completion: { (completed) in
    self.presentingViewController.view.alpha = 1.0
    self.finishAnimation(completion: nil)
  })
}

As you may have guessed, you have different properties. The main ones:

  • duration — transition duration

  • presentingViewController — the presenting view controller (bottom one)

  • presentedViewController — view controller that is going to be presented (top one)

You can animate them as you want.

code4app

相关源码推荐:

我来说两句
*滑动验证:
所有评论(5)
phoiu 2017-1-3 15:46:09
小弟学习了~支持,支持
回复
BlueManlove 2017-1-3 15:47:13
相当不错,感谢无私分享精神!
回复
kengsir 2017-1-3 15:48:41
帮帮顶顶!!
回复
littleRed 2017-1-3 15:50:04
感谢大神~
回复
hellokenken 2017-1-3 15:55:26
感谢大神分享,必须顶!
回复
AlonMessi 2017-1-3 16:00:35
不错不错,楼主辛苦了。。。
回复
xiamenios 2017-1-3 16:08:46
正需要啊,感谢楼主无私分享!
回复
code4app热心网友 2017-1-3 17:29:54
我只是路过打酱油的。
回复
DanbLee 2017-1-3 22:00:30
我只是路过打酱油的。
回复
提取码:  下载次数:61 状态:已购或VIP 售价:0(原价:10)金钱 下载权限:初级码农 
1006 0 61
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表