Created
February 27, 2024 16:16
-
-
Save kurtroberts/7cadbd06c5f7ad0fd5c659f01c1c4963 to your computer and use it in GitHub Desktop.
Using a SwiftUI layout inside a UIKit View Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ExampleSwiftUIView.swift | |
// Example | |
// | |
// Created by Kurt Roberts on 2/26/24. | |
// | |
import SwiftUI | |
struct ExampleSwiftUIView: View { | |
var body: some View { | |
VStack { | |
Image(systemName: "globe") | |
.imageScale(.large) | |
.foregroundStyle(.tint) | |
Text("Knock, knock!") | |
} | |
.padding() | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ExampleViewController.swift | |
// Example | |
// | |
// Created by Kurt Roberts on 2/27/24. | |
// | |
import UIKit | |
import SwiftUI | |
final class ExampleViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let vc = UIHostingController(rootView: ExampleSwiftUIView()) | |
present(vc, animated: true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment