Last updated 3 years ago
Was this helpful?
ViewPreference - custom type.
PreferenceKey - built-in type.
Anchor Preferences
What are View Preferences❓
It’s a way to send configuration data up the view hierarchy.
問:如何使用 view preference❓
設計一個遵循 協定的類別。
使用 childview. 來設定要往上傳的資料。
使用 parentview. 讓上層決定如何回應。(通常會在 這個 closure parameter 裡面改變 view ,藉此讓 view 有更新或重新 layout 的機會)
parentview 也可以使用 .() 或 .() 來增加一個 background 或 overlay。
.readSize() - read a view's size.
Mark van Wijnen ⟩
Arda C. Tugay ⟩ Diving Deep into SwiftUI ⟩
SwiftOnTap ⟩
⟩
.
⟩ ⟩ ⟩
.()
view layout ⟩ Adaptive Layout