回答編集履歴

1

ボタンを初期化した時の位置・サイズで固定されるようにした。あとなんか自信満々で言い切っていたのが恥ずかしいので提案口調にした

2016/01/21 15:05

投稿

u39ueda
u39ueda

スコア950

test CHANGED
@@ -1,8 +1,4 @@
1
- スマホなんで手抜きです。表示が崩れてたらごめんなさい。帰ったら編集します。
2
-
3
-
4
-
5
- コードを見る限り右下に固定したいのに左上に固定されてしまうという状況だと推測します。
1
+ コードを見る限り右下から20px離した位置に固定したいのに左上に固定されてしまうという状況だと推測します。
6
2
 
7
3
 
8
4
 
@@ -12,9 +8,19 @@
12
8
 
13
9
  ```
14
10
 
11
+ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
12
+
13
+
14
+
15
15
  CGPoint point = CGPointMake(self.settingsButton.frame.size.width +scrollView.contentOffset.x,
16
16
 
17
17
  self.settingsButton.frame.size.height + scrollView.contentOffset.y);
18
+
19
+
20
+
21
+ self.settingsButton.frame = CGRectMake(point.x,point.y,50,50);
22
+
23
+ }
18
24
 
19
25
  ```
20
26
 
@@ -22,17 +28,29 @@
22
28
 
23
29
  ここを
24
30
 
25
- ```
26
31
 
27
- CGPoint point = CGPointMake(scrollView.contentOffset.x + screenFrame.size.width -52 - self.settingsButton.frame.size.width,
28
32
 
33
+ ```Objective-C
34
+
35
+ - (void)scrollViewDidScroll:(UIScrollView *)scrollView {
36
+
37
+ CGRect screenFrame = self.view.bounds;
38
+
39
+ CGRect buttonFrame = self.settingsButton.frame;
40
+
41
+ buttonFrame.origin = CGPointMake(scrollView.contentOffset.x + screenFrame.size.width - 20.0 - buttonFrame.size.width,
42
+
29
- scrollView.contentOffset.y + screenFrame.size.height -52 - self.settingsButton.frame.size.height);
43
+ scrollView.contentOffset.y + screenFrame.size.height - 20.0 - buttonFrame.size.height);
44
+
45
+ self.settingsButton.frame = buttonFrame;
46
+
47
+ }
30
48
 
31
49
  ```
32
50
 
33
51
 
34
52
 
35
- に変えればいいと思います
53
+ に変えてみてはどうでしょうか
36
54
 
37
55
 
38
56