code:
import SwiftUI
struct ContentView: View {
let screenWidth = UIScreen.main.bounds.width
var body: some View {
ZStack {
Color.yellow
.edgesIgnoringSafeArea(.all)
Text("Hello, World!")
Text("Study Swift")
.position(CGPoint(x: screenWidth/2, y: 400))
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Result:
Reference:
How to set a background color for the viewController in swiftUI? (StackOverflow)
No comments:
Post a Comment