Я перехожу с Storyboard на Swift UI.
Я сделал следующее:
< ol>
[*]Создайте HostingViewController в основной раскадровке.
[*]Создайте быстрый файл с именем NotificationVC.
[*]Подключите NotificationVC в раскадровке.
Проблема в том, что цвет фона строки состояния и самый низ черный, а не белый.

Я пытался найти переполнение стека, но не нашел подходящего решения
Есть идеи, как это исправить?
import UIKit
import SwiftUI
struct NotificationScreen: View {
var body: some View {
ZStack {
Color.white
.ignoresSafeArea(edges: .all) // Ensure it covers the entire screen, including the unsafe area
VStack {
Text("Hello!")
.foregroundColor(.white)
}
}
}
}
#Preview {
NotificationScreen()
}
class NotificationVC: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let swiftUIView = NotificationScreen()
let hostingController = UIHostingController(rootView: swiftUIView)
addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.didMove(toParent: self)
}
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... and-bottom
Мобильная версия