//
// TurnAnimation.swift
// TurnAnimation
//
// Created by 王渊博 on 15/12/2.
// Copyright © 2015年 浮云千载唯忆君颜. All rights reserved.
//
import UIKit
import QuartzCore
class TurnAnimation: NSObject {
// 旋转动画
class func turnAnimationWithAnimaView(animaView animaView: UIView, fromValue: AnyObject, toValue: AnyObject, duration: CFTimeInterval) {
// 旋转
let animation = CATransition.init()
animation.duration = 0.1
animation.repeatCount = 5
animation.fillMode = kCAFillModeForwards
animation.removedOnCompletion = false
animation.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionLinear)
animation.type = "oglFlip"
animation.subtype = "fromLeft"
animaView.layer.addAnimation(animation, forKey: nil)
// 缩放
let anima = CABasicAnimation.init(keyPath: "transform.scale")
anima.fillMode = kCAFillModeForwards
anima.removedOnCompletion = false
anima.fromValue = fromValue // as AnyObject
anima.toValue = toValue // as AnyObject
anima.duration = duration
anima.autoreverses = false
anima.repeatCount = 1
animaView.layer.addAnimation(anima, forKey: nil)
animaView.layer.fillMode = kCAFillModeForwards
}
// 圆形动画
class func keyframeAnimation(animaView: UIView, rect: CGRect, duration: CFTimeInterval, repeatCount: Float) {
// 路径
let ctx = UIGraphicsGetCurrentContext()
let path = CGPathCreateMutable()
CGPathAddEllipseInRect(path, nil, rect)
CGContextAddPath(ctx, path)
CGContextStrokePath(ctx)
let animation = CAKeyframeAnimation.init(keyPath: "position")
animation.path = path
animation.removedOnCompletion = false
animation.fillMode = kCAFillModeForwards
animation.timingFunction = CAMediaTimingFunction.init(name: kCAMediaTimingFunctionEaseIn)
animation.autoreverses = false
animation.duration = duration
animation.repeatCount = repeatCount
animaView.layer.addAnimation(animation, forKey: "position")
}
}
Swift2垂直旋转+放大动画代码
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- // UIView如果使用AutoLayout 必须写此方法 //按钮的动态效果修改时 此方法为 系统自带方法 /...
- “每日一练”刚开始一天就遭到了一些阻力,似乎该改名叫"每周一练"ORZ。。。还是再逼迫自己坚持一下试试(ˇˍˇ)...