回答編集履歴
3
追記
answer
CHANGED
@@ -52,4 +52,6 @@
|
|
52
52
|
return Int(UIScreen.mainScreen().bounds.size.height);
|
53
53
|
}
|
54
54
|
}
|
55
|
-
```
|
55
|
+
```
|
56
|
+
|
57
|
+

|
2
追記
answer
CHANGED
@@ -25,4 +25,31 @@
|
|
25
25
|
|
26
26
|
print(UIScreenUtil.screenHeight())
|
27
27
|
//=> 568
|
28
|
+
```
|
29
|
+
|
30
|
+
```swift
|
31
|
+
import UIKit
|
32
|
+
|
33
|
+
class ViewController: UIViewController {
|
34
|
+
|
35
|
+
override func viewDidLoad() {
|
36
|
+
super.viewDidLoad()
|
37
|
+
|
38
|
+
// メソッド呼び出し
|
39
|
+
print(UIScreenUtil.bounds())
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
|
44
|
+
struct UIScreenUtil {
|
45
|
+
static func bounds()->CGRect{
|
46
|
+
return UIScreen.mainScreen().bounds;
|
47
|
+
}
|
48
|
+
static func screenWidth()->Int{
|
49
|
+
return Int( UIScreen.mainScreen().bounds.size.width);
|
50
|
+
}
|
51
|
+
static func screenHeight()->Int{
|
52
|
+
return Int(UIScreen.mainScreen().bounds.size.height);
|
53
|
+
}
|
54
|
+
}
|
28
55
|
```
|
1
追記
answer
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
上記の構造体のメソッドはstaticなメソッドなので以下の様に呼び出した結果
|
2
2
|
問題なく実行したiPhoneの画面サイズを取得できました。
|
3
3
|
|
4
|
+
structがclassのスコープの中に入っているようにもとれますが、外に出してくださいね。
|
4
5
|
まだ分からなところがありました質問ください。
|
5
6
|
|
6
7
|
iPhone6Sで実行した場合
|