.tint

I am very knew to SwiftUL. First first Projectv was to copy a working SwiftUL code as follows:

// // ContentView.swift // Project2 // // Created by Ian Steward on 10/20/24. // import SwiftUI

struct ContentView: View { var body: some View { VStack(spacing: 20) { Text("SwiftUI Button") .font(.largeTitle) Text("Enabled & Disabled") .font(.title) .foregroundColor(.gray)

  /* Disabled */
  Button("Enabled") {}
    .buttonStyle(.borderedProminent)
    .tint(.blue)
    .controlSize(.large)
  
  Button("Disabled") {}
    .buttonStyle(.borderedProminent)
    .tint(.blue)
    .controlSize(.large)
    .disabled(true)
}

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

I get and error saying: "Reference to member 'tint' cannot be resolved without a contextual type" on both both lines that have .tint(.blue)

Any ideas on how to correct the issue

Answered by Claude31 in 810122022

Welcome to the forum.

When you post code, please use the code formatter tool:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack(spacing: 20) {
            Text("SwiftUI Button")
                .font(.largeTitle)
            Text("Enabled & Disabled")
                .font(.title)
                .foregroundColor(.gray)
            /* Disabled */
            Button("Enabled") {}
                .buttonStyle(.borderedProminent)
                .tint(.blue)
                .controlSize(.large)
            
            Button("Disabled") {}
                .buttonStyle(.borderedProminent)
                .tint(.blue)
                .controlSize(.large)
                .disabled(true)
        }
    }
}

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

I tested on iOS simulator, it works

Welcome to the forum.

When you post code, please use the code formatter tool:

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack(spacing: 20) {
            Text("SwiftUI Button")
                .font(.largeTitle)
            Text("Enabled & Disabled")
                .font(.title)
                .foregroundColor(.gray)
            /* Disabled */
            Button("Enabled") {}
                .buttonStyle(.borderedProminent)
                .tint(.blue)
                .controlSize(.large)
            
            Button("Disabled") {}
                .buttonStyle(.borderedProminent)
                .tint(.blue)
                .controlSize(.large)
                .disabled(true)
        }
    }
}

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

I tested on iOS simulator, it works

.tint
 
 
Q