🔰view layout
SwiftUI layout system:
Parent proposes a size for child.
Child chooses its own size.
Parent places child in parent’s coordinate space.
SwiftUI views manage size in different ways:
"push-out" views: expand to fill space offered by parent. 👉
Color
,LinearGradient
,Circle
..."pull-in" views: have ideal size that varies according to their contents. 👉
Text
, container views (HStack, VStack , ...)"fixed" views: have ideal size that never varies. 👉
Toggle
orDatePicker
...
知乎 ⟩ SwiftUI 成神之路 ⟩ SwiftUI 之 Layout 基礎篇
GeometryReader is often used to do custom layout.
Cannot convert value of type 'Self' to expected argument type 'Binding<C>' ⛔️ error occurred when designing protocol for layout.
Last updated
Was this helpful?