//
// ViewController.swift
// 图标抖动
//
// Created by admin on 16/1/27.
// Copyright © 2016年 jin. All rights reserved.
//
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var imageView: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func start(sender: AnyObject) {
let animation = CAKeyframeAnimation(keyPath: "transform.rotation")
// 设置path
animation.values = [-CGFloat(M_PI * 0.1),CGFloat(M_PI * 0.1),-CGFloat(M_PI * 0.1)]
// 设置重复次数
animation.repeatCount = Float(CGFloat.max)
self.imageView.layer.addAnimation(animation, forKey: "shark")
}
@IBAction func stop(sender: AnyObject) {
// 停止动画
self.imageView.layer.removeAnimationForKey("shark")
}
}