Код: Выделить всё
struct SettingsSUView: View {
@State private var isPresented = false
@State private var isDarkMode = true
var body: some View {
Button("Show Sheet") {
isPresented = true
}
.sheet(isPresented: $isPresented) {
List {
Toggle("Dark Mode", isOn: $isDarkMode)
}
.preferredColorScheme(isDarkMode ? .dark : .light)
}
}
}
#Preview {
SettingsSUView()
}
Код: Выделить всё
let contentHostingController = UIHostingController(rootView: SettingsSUIView())
addChild(contentHostingController)
view.addSubview(contentHostingController.view)
contentHostingController.view.snp.makeConstraints { make in
make.edges.equalToSuperview()
}
contentHostingController.didMove(toParent: self)
Подробнее здесь: https://stackoverflow.com/questions/780 ... stingcontr
Мобильная версия