回答編集履歴
3
追記
test
CHANGED
@@ -60,7 +60,7 @@
|
|
60
60
|
|
61
61
|
@objc func imageTapped() {
|
62
62
|
|
63
|
-
rotateImage(degree:90, imageview: self.imageView)
|
63
|
+
self.rotateImage(degree:90, imageview: self.imageView)
|
64
64
|
|
65
65
|
}
|
66
66
|
|
@@ -73,3 +73,9 @@
|
|
73
73
|
これで大丈夫だと思います。
|
74
74
|
|
75
75
|
試してみください。
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
ちなみにtouchesBeganやtouchesMovedに
|
80
|
+
|
81
|
+
imageTappedの中身を書いても同じ動きすると思います。
|
2
コード編集
test
CHANGED
@@ -64,7 +64,7 @@
|
|
64
64
|
|
65
65
|
}
|
66
66
|
|
67
|
-
|
67
|
+
}
|
68
68
|
|
69
69
|
```
|
70
70
|
|
1
サンプル追加
test
CHANGED
@@ -5,3 +5,71 @@
|
|
5
5
|
|
6
6
|
|
7
7
|
https://i-app-tec.com/ios/cgaffinetransform.html
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
ちょっと時間があったので、サンプル作ってみました。
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
```swift
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
import UIKit
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
class SampleViewController: UIViewController {
|
26
|
+
|
27
|
+
@IBOutlet var imageView:UIImageView!
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
override func viewDidLoad() {
|
32
|
+
|
33
|
+
super.viewDidLoad()
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(SampleViewController.imageTapped))
|
38
|
+
|
39
|
+
self.imageView.addGestureRecognizer(tapGesture)
|
40
|
+
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
func rotateImage(degree: Int, imageview: UIImageView){
|
46
|
+
|
47
|
+
let angle = CGFloat(degree) * CGFloat.pi / 180
|
48
|
+
|
49
|
+
let transRotate = CGAffineTransform(rotationAngle: CGFloat(angle));
|
50
|
+
|
51
|
+
imageview.transform = transRotate
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
print("Rotate: (angle)")
|
56
|
+
|
57
|
+
}
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
@objc func imageTapped() {
|
62
|
+
|
63
|
+
rotateImage(degree:90, imageview: self.imageView)
|
64
|
+
|
65
|
+
}
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
```
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
これで大丈夫だと思います。
|
74
|
+
|
75
|
+
試してみください。
|