質問編集履歴
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,4 +12,39 @@
|
|
12
12
|
|
13
13
|
ヒントでも良いのでお願いします。
|
14
14
|
|
15
|
+
```
|
16
|
+
import Charts
|
17
|
+
|
18
|
+
@IBOutlet weak var pieChartsView: PieChartView!
|
19
|
+
var buttonStartFlg = true
|
20
|
+
@IBOutlet weak var startButton: UIButton!
|
21
|
+
|
22
|
+
...
|
23
|
+
|
24
|
+
// MARK: - Action
|
25
|
+
@IBAction func tapStartButton(_ sender: UIButton) {
|
26
|
+
|
27
|
+
let animation = CABasicAnimation(keyPath: "transform.rotation")
|
28
|
+
animation.isRemovedOnCompletion = false
|
29
|
+
animation.fillMode = CAMediaTimingFillMode.forwards
|
30
|
+
|
31
|
+
if buttonStartFlg {
|
32
|
+
startButton.setImage(UIImage(named: "stop"), for: .normal)
|
33
|
+
pieChartsView.layer.speed = 2.0
|
34
|
+
animation.toValue = .pi / 2.0
|
35
|
+
animation.duration = 0.1
|
36
|
+
animation.repeatCount = MAXFLOAT
|
37
|
+
animation.isCumulative = true
|
38
|
+
pieChartsView.layer.add(animation, forKey: "ImageViewRotation")
|
39
|
+
buttonStartFlg = false
|
40
|
+
} else {
|
41
|
+
startButton.setImage(UIImage(named: "start"), for: .normal)
|
42
|
+
let pausedTime = pieChartsView.layer.convertTime(CACurrentMediaTime(), from: nil)
|
43
|
+
pieChartsView.layer.speed = 0.0
|
44
|
+
pieChartsView.layer.timeOffset = pausedTime
|
45
|
+
buttonStartFlg = true
|
46
|
+
}
|
47
|
+
}
|
48
|
+
```
|
49
|
+
|
15
50
|

|