iosswiftswiftuiipad

SwiftUI Header/Title Text Background Color Screen Wide


I want to set the background color for "Sebastian's Favorite Stuff" to encompass the entire area. Currently it looks like this and I want to cover the white spaces.

App Layout

My Code is as follows:

var body: some View {
    VStack{
        GridRow{
            Text("SEBASTIAN'S FAVORITE STUFF")
                .lineLimit(1)
                .padding(10)
                .font(.system(size: 500))
                .minimumScaleFactor(0.01)
                .colorInvert()
        }
        .background(Color(red: 0.18 , green: 0.59 , blue: 0.65 ))
        HStack{
            ScrollView{
                Grid{

What do I need to adjust so it fills the area and not just the text background?


Solution

  • If you chain .frame(maxWidth: .infinity) on the Text as the last modifier, the background color should extend to the left and right edges.