-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRatationViewController.swift
56 lines (43 loc) · 1.57 KB
/
RatationViewController.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//
// RatationViewController.swift
// iOSAnimation
//
// Created by 张朝伟 on 15/11/14.
// Copyright © 2015年 zcw. All rights reserved.
//
import UIKit
class RatationViewController: UIViewController {
@IBOutlet weak var image: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
/**
options: UIViewAnimationOptions.CurveLinear - 控制匀速转动 线性关系(还有很多类型可查看官方文档)
animations{}执行动画
后面那个闭包 是执行完动画后执行的动作
*/
func spin () {
UIView.animateWithDuration(0.5, delay: 0, options: UIViewAnimationOptions.CurveLinear, animations: {
self.image.transform = CGAffineTransformRotate(self.image.transform, CGFloat(M_PI))
}) { (finished) -> Void in
self.spin()
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.spin()
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}