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
// Present hostingController | |
let hostingController = UIHostingController(rootView: SettingsView()) | |
present(hostingController, animated: true, completion: nil) | |
// Push hostingController | |
let hostingController = UIHostingController(rootView: SettingsView()) | |
navigationController?.pushViewController(hostingController, animated: true) |
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
struct SearchBar: UIViewRepresentable { | |
@Binding var text: String | |
class Coordinator: NSObject, UISearchBarDelegate { | |
@Binding var text: String | |
init(text: Binding<String>) { | |
_text = text | |
} |
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
private func addSettingsView() { | |
let settingsView = SettingsView() | |
let hostingController = UIHostingController(rootView: settingsView) | |
addChild(hostingController) | |
view.addSubview(hostingController.view) | |
hostingController.view.translatesAutoresizingMaskIntoConstraints = false | |
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true | |
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor).isActive = true | |
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true |
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
import SwiftUI | |
class SettingsViewController: UIHostingController<SettingsView> { | |
override init(rootView: SettingsView) { | |
super.init(rootView: rootView) | |
tabBarItem = UITabBarItem(title: "Settings", image: UIImage(systemName: "gearshape"), selectedImage: UIImage(systemName: "gearshape.fill")) | |
} | |
required init?(coder aDecoder: NSCoder) { |