Browse Questions
  • GeometryReader is a container view that exposes the size and coordinate space of its parent, letting you build size-dependent layouts.
  • Use protoc with the Swift plugin to generate Swift files from a .proto file provided by the backend team.
  • Copy-on-write means a value type shares its underlying storage with copies until one of them is mutated — only then is a real copy made.
  • TLS protects the connection, not the message — it ends at the first thing that terminates it, which may be a load balancer, a logging proxy, or an attacker's intercepting certificate on a…

Answer: GeometryReader is a container view that exposes the size and coordinate space of its parent, letting you build size-dependent layouts. However it comes with notable downsides.

Code Example:

struct ProportionalView: View {
    var body: some View {
        GeometryReader { geometry in
            Rectangle()
                .frame(width: geometry.size.width * 0.5,
                       height: geometry.size.height * 0.3)
        }
    }
}

Pitfalls:

  • Expands to fill all available space by default — can break layouts
  • Triggers layout recalculation which can hurt performance
  • Avoid wrapping simple views in it unnecessarily

Better alternatives in many cases:

// Use .containerRelativeFrame for proportional sizing (iOS 17+)
Rectangle()
    .containerRelativeFrame(.horizontal) { size, _ in size * 0.5 }