質問するログイン新規登録

質問編集履歴

3

見やすくしました。

2019/07/07 09:35

投稿

harago
harago

スコア11

title CHANGED
File without changes
body CHANGED
@@ -4,8 +4,9 @@
4
4
  tinderUIを実現させたくswiftでコードを書いているのですが、xcodeのdebugモードで確認するとカードが動きません。
5
5
  初心者で右往左往しておりますがご教示いただけますと幸いです。
6
6
 
7
- ```swift
7
+ #コード
8
8
 
9
+ ```
9
10
  //
10
11
  // ViewController.swift
11
12
  // Piluser

2

コードを見やすくしました、

2019/07/07 09:35

投稿

harago
harago

スコア11

title CHANGED
File without changes
body CHANGED
@@ -4,7 +4,8 @@
4
4
  tinderUIを実現させたくswiftでコードを書いているのですが、xcodeのdebugモードで確認するとカードが動きません。
5
5
  初心者で右往左往しておりますがご教示いただけますと幸いです。
6
6
 
7
- #コード
7
+ ```swift
8
+
8
9
  //
9
10
  // ViewController.swift
10
11
  // Piluser
@@ -90,4 +91,4 @@
90
91
  }
91
92
 
92
93
  }
93
- }
94
+ }```

1

改行などをしコードを見やすくしました。

2019/07/07 09:34

投稿

harago
harago

スコア11

title CHANGED
File without changes
body CHANGED
@@ -29,8 +29,6 @@
29
29
  var people = [UIView]()
30
30
  var selectedCardCount: Int = 0
31
31
 
32
-
33
-
34
32
  override func viewDidLoad() {
35
33
  super.viewDidLoad()
36
34
  centerOfCard = basicCard.center
@@ -48,14 +46,13 @@
48
46
  card.center = CGPoint(x: card.center.x + point.x, y: card.center.y + point.y)
49
47
  people[selectedCardCount].center = CGPoint(x: card.center.x + point.x, y: card.center.y + point.y)
50
48
 
49
+
51
50
  //角度を変える
52
51
  let xFromCenter = card.center.x - view.center.x
53
52
  card.transform = CGAffineTransform(rotationAngle: xFromCenter / (view.frame.width / 2) * -0.785)
54
53
  people[selectedCardCount].transform = CGAffineTransform(rotationAngle: xFromCenter / (view.frame.width / 2) * -0.785)
55
54
 
56
-
57
-
58
- if xFromCenter > 0 {
55
+ if xFromCenter > 0 {
59
56
  //likeImageView.image = good
60
57
  likeImageView.alpha = 1
61
58
  likeImageView.tintColor = UIColor.red
@@ -66,14 +63,15 @@
66
63
  }
67
64
 
68
65
 
69
-
70
66
  if sender.state == UIGestureRecognizer.State.ended {
67
+
71
68
  //左に大きくスワイプ
72
69
  if card.center.x < 75 {
73
70
  UIView.animate(withDuration: 0.2, animations: {
74
71
  card.center = CGPoint (x: card.center.x - 250, y: card.center.y )
75
72
  })
76
73
  return
74
+
77
75
  //右に大きくスワイプ
78
76
  } else if card.center.x > self.view.frame.width - 75 {
79
77
  UIView.animate(withDuration: 0.2, animations: {