我不认为\xe2\x80\x99t 存在\xe2\x80\x99s 一种投射方式,但您可以基于第一个绑定创建另一个绑定:
\n\nimport SwiftUI\nvar d = 1.0\n// Create a Binding<Double> (for lack of another source)\nvar bd = Binding<Double>(get: { d }, set: { d = $0 })\n// "Convert" to Binding<Int> by recreating another Binding\nlet bi = Binding<Int>(get: { Int(bd.wrappedValue) },\n set: { bd.wrappedValue = Double($0) })\n
Run Code Online (Sandbox Code Playgroud)\n
归档时间: |
|
查看次数: |
3437 次 |
最近记录: |