SwiftUI_Method_BInd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
struct ContentView: View { | |
@ObservedObject var bind = STBind() | |
init() { | |
bind.st = "111" | |
} | |
var body: some View { | |
VStack { | |
Text(self.a(st: bind)) | |
.onTapGesture { | |
if self.bind.st == "111" { | |
self.bind.st = "222" | |
} else { | |
self.bind.st = "111" | |
} | |
} | |
} | |
} | |
func a(st: STBind) -> String { | |
return st.st | |
} | |
} | |
class STBind: ObservableObject { | |
@Published var st = String() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
daisukenagata commentedJul 19, 2020