//
// TurnAnimation.swift
// TurnAnimation
//
// Created by 王淵博 on 15/12/2.
// Copyright ? 2015年 浮云千載唯憶君顏. All rights reserved.
//
import UIKit
import QuartzCore
class TurnAnimation: NSObject {
// 旋轉(zhuǎn)動畫
class func turnAnimationWithAnimaView(animaView animaView: UIView, fromValue: AnyObject, toValue: AnyObject, duration: CFTimeInterval) {
// 旋轉(zhuǎn)
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垂直旋轉(zhuǎn)+放大動畫代碼
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
- 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來虎韵,“玉大人易稠,你說我怎么就攤上這事“叮” “怎么了驶社?”我有些...
- 文/不壞的土叔 我叫張陵,是天一觀的道長测萎。 經(jīng)常有香客問我亡电,道長,這世上最難降的妖魔是什么硅瞧? 我笑而不...
- 正文 為了忘掉前任份乒,我火速辦了婚禮,結(jié)果婚禮上腕唧,老公的妹妹穿的比我還像新娘或辖。我一直安慰自己,他們只是感情好枣接,可當我...
- 文/花漫 我一把揭開白布颂暇。 她就那樣靜靜地躺著,像睡著了一般但惶。 火紅的嫁衣襯著肌膚如雪耳鸯。 梳的紋絲不亂的頭發(fā)上,一...
- 文/蒼蘭香墨 我猛地睜開眼纲缓,長吁一口氣:“原來是場噩夢啊……” “哼卷拘!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起祝高,我...
- 正文 年R本政府宣布,位于F島的核電站壶冒,受9級特大地震影響缕题,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜胖腾,卻給世界環(huán)境...
- 文/蒙蒙 一烟零、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧胸嘁,春花似錦瓶摆、人聲如沸。這莊子的主人今日做“春日...
- 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至毫胜,卻和暖如春书斜,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背酵使。 一陣腳步聲響...
推薦閱讀更多精彩內(nèi)容
- // UIView如果使用AutoLayout 必須寫此方法 //按鈕的動態(tài)效果修改時 此方法為 系統(tǒng)自帶方法 /...
- http://www .jq-school.com/Show.aspx?id=281
- “每日一練”剛開始一天就遭到了一些阻力瞬沦,似乎該改名叫"每周一練"ORZ。雇锡。逛钻。還是再逼迫自己堅持一下試試(ˇ?ˇ)...
- 1. 相信愛,它便會帶你到你需要去的地方遮糖。 相信你所愛的事情绣的,堅持做下去叠赐,它便帶你到你需要的地方去欲账。 2. 任何事...