Cannot infer contextual base in reference to member 'background'

Started following Apple's Develop in Swift tutorials and was met with the error in the title.

//  ContentView.swift
//  OnboardingView
//
//  
//

import SwiftUI

extension Color {
    static var gradientTop = Color("gradientTop")
    static var gradientBottom = Color("gradientBottom")
}

let gradientColors: [Color] = [
    .gradientTop,
    .gradientBottom
]

struct ContentView: View {
    var body: some View {
        .background(Gradient(colors: gradientColors))
        TabView {
            WelcomePage()
            FeaturesPage()
        }
        .tabViewStyle(.page)
    }
}

struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

Xcode 13.2.1 used for compatibility reasons.

You've put the .background modifier at the very beginning of your view. Do you know how object-oriented programming works? An object has a bunch of properties, and you access using the dot notation, so:

MyObject
    .background(Color.red)

What you've done is tried to apply a modifier to... nothing.

Where do you want the gradient? Behind the TabView? Put the .background modifier on the TabView, i.e.:

TabView {
    WelcomePage()
    FeaturesPage()
}
.tabViewStyle(.page)
.background(Gradient(colors: gradientColors))
Cannot infer contextual base in reference to member 'background'
 
 
Q