質問編集履歴
1
参考画像の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -31,3 +31,65 @@
|
|
31
31
|
|
32
32
|
|
33
33
|
![イメージ説明](8ae1a1b8519a44016c4f6862bc9eb10b.png)
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
```swift
|
38
|
+
|
39
|
+
import SwiftUI
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
class ViewController: UIViewController {
|
44
|
+
|
45
|
+
override func viewDidLoad() {
|
46
|
+
|
47
|
+
super.viewDidLoad()
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
let vc: UIHostingController = UIHostingController(rootView: SubView())
|
52
|
+
|
53
|
+
self.addChild(vc)
|
54
|
+
|
55
|
+
self.view.addSubview(vc.view)
|
56
|
+
|
57
|
+
vc.didMove(toParent: self)
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
vc.view.translatesAutoresizingMaskIntoConstraints = false
|
62
|
+
|
63
|
+
vc.view.heightAnchor.constraint(equalToConstant: 320).isActive = true
|
64
|
+
|
65
|
+
vc.view.leftAnchor.constraint(equalTo: self.view.leftAnchor, constant: 16).isActive = true
|
66
|
+
|
67
|
+
vc.view.rightAnchor.constraint(equalTo: self.view.rightAnchor, constant: -16).isActive = true
|
68
|
+
|
69
|
+
vc.view.centerYAnchor.constraint(equalTo: self.view.centerYAnchor).isActive = true
|
70
|
+
|
71
|
+
}
|
72
|
+
|
73
|
+
}
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
struct SubView : View {
|
78
|
+
|
79
|
+
var body: some View {
|
80
|
+
|
81
|
+
Text("にゃーん????")
|
82
|
+
|
83
|
+
}
|
84
|
+
|
85
|
+
}
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
```
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
![イメージ説明](5a96b4247c66bbf53b17a83cc9a58db2.png)
|