New to SwifUI. Trying to attach property to an image or button to set a foregroundColor to green or red depending on the time of day. Also get the same error with .padding() and .border Assume cause is the same for all so limited example to one property.
It appears I cannot conditionally set a property because when I try I get "cannot infer contextual base in reference to member"
The function worked and made calls based on the passed argument. Problem appeared after conditionally trying to set foreground.Color
Simple experimental code:
@State private var phoneNumber = " "
Button { phoneNumber = "XXX-XXX-XXXX" callout(phonenum: phoneNumber) } label { Text("Using function to call") if oktime > nowtime { .foregroundColor.green } else { .foregroundColor.red } }
Please point me in the right direction. Googled the problem and became more confused.
Thanks in advance, D