Make a VStack fill the width of the screen in SwiftUI

前端 未结 14 1671
失恋的感觉
失恋的感觉 2020-12-07 16:58

Given this code :

import SwiftUI

struct ContentView : View {
    var body: some View {
        VStack(alignment: .leading) {
            Text(\"Title\")
            


        
14条回答
  •  温柔的废话
    2020-12-07 17:49

    The simplest way I manage to solve the issue was is by using a ZStack + .edgesIgnoringSafeArea(.all)

    struct TestView : View {
    
        var body: some View {
            ZStack() {
                Color.yellow.edgesIgnoringSafeArea(.all)
                VStack {
                    Text("Hello World")
                }
            }
        }
    }
    

提交回复
热议问题