'requires that 'moveView' conform to 'StringProtocol' in swiftui
I have a struct to pass the ObservedObject value change.
struct moveView : View {
@Binding var move : Bool
var body: some View {
if move{
return Text("1")
}else{
return Text("2")
}
}
}
struct TextView : View {
@ObservedObject var skc:xiangcene
var body: some View {
Text("test")
.opacity(moveView(move: $skc.move) == "1" ? 0.1 : 0.8) // <- error on this line
}
}
The compiler gives the following error:
Referencing operator function
==onStringProtocolrequires thatmoveViewconform toStringProtocol
How can i fix that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
