質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -26,4 +26,74 @@
|
|
26
26
|
|
27
27
|
|
28
28
|
|
29
|
+
```
|
30
|
+
|
31
|
+
import Charts
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
@IBOutlet weak var pieChartsView: PieChartView!
|
36
|
+
|
37
|
+
var buttonStartFlg = true
|
38
|
+
|
39
|
+
@IBOutlet weak var startButton: UIButton!
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
...
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
// MARK: - Action
|
48
|
+
|
49
|
+
@IBAction func tapStartButton(_ sender: UIButton) {
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
let animation = CABasicAnimation(keyPath: "transform.rotation")
|
54
|
+
|
55
|
+
animation.isRemovedOnCompletion = false
|
56
|
+
|
57
|
+
animation.fillMode = CAMediaTimingFillMode.forwards
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
if buttonStartFlg {
|
62
|
+
|
63
|
+
startButton.setImage(UIImage(named: "stop"), for: .normal)
|
64
|
+
|
65
|
+
pieChartsView.layer.speed = 2.0
|
66
|
+
|
67
|
+
animation.toValue = .pi / 2.0
|
68
|
+
|
69
|
+
animation.duration = 0.1
|
70
|
+
|
71
|
+
animation.repeatCount = MAXFLOAT
|
72
|
+
|
73
|
+
animation.isCumulative = true
|
74
|
+
|
75
|
+
pieChartsView.layer.add(animation, forKey: "ImageViewRotation")
|
76
|
+
|
77
|
+
buttonStartFlg = false
|
78
|
+
|
79
|
+
} else {
|
80
|
+
|
81
|
+
startButton.setImage(UIImage(named: "start"), for: .normal)
|
82
|
+
|
83
|
+
let pausedTime = pieChartsView.layer.convertTime(CACurrentMediaTime(), from: nil)
|
84
|
+
|
85
|
+
pieChartsView.layer.speed = 0.0
|
86
|
+
|
87
|
+
pieChartsView.layer.timeOffset = pausedTime
|
88
|
+
|
89
|
+
buttonStartFlg = true
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
}
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
|
98
|
+
|
29
99
|
![イメージ説明](d3eea021a6a06309fe7c6814784b7dc6.png)
|