SwiftUI - How do I change the background color of a View?

后端 未结 13 1156
渐次进展
渐次进展 2020-12-13 11:53

I\'m beginning to try out SwiftUI and I\'m surprised that it doesn\'t seem to be straightforward to change the background color of a View. How do y

相关标签:
13条回答
  • 2020-12-13 12:29

    Xcode 11.5

    Simply use ZStack to add background color or images to your main view in SwiftUI

    struct ContentView: View {
        var body: some View {
            ZStack {
                Color.black
            }
            .edgesIgnoringSafeArea(.vertical)
        }
    }
    
    0 讨论(0)
提交回复
热议问题