I have the following chunk of code in a SwiftUI
app:
struct BtnTxtView: View {
var theLabel:String
var highLight: Bool
var body: some View {
let crnrRad:CGFloat = 5.0
Text(theLabel)
.foregroundColor(.blue)
.padding(.vertical)
.font(.largeTitle)
.if (highLight) { $0
.cornerRadius(crnrRad)
.overlay(RoundedRectangle(cornerRadius: crnrRad)
.stroke(Color.purple, lineWidth: 4.0))
}
}
}
I get this error message:
Value of type 'some View' has no member 'if'
on the line:
.if (highLight) { $0
Having used this type of syntax in another project without any issue I did this test:
I copied the chunk of code above and put it in my other project and tried to compile.
I get absolutely no error. Why is that?
Can anyone think of a possible reason, why I see an error in one case and not the other?