Created
July 19, 2020 17:31
-
-
Save DaisukeNagata/c6af55ae7896e8198492b0c0d9168396 to your computer and use it in GitHub Desktop.
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() | |
} |
Author
DaisukeNagata
commented
Jul 19, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment