DevPrep

All topics › SwiftUI

What is GeometryReader and why shouldn't you overuse it?

Middle PRO

The gist

GeometryReader is a container that passes a GeometryProxy into its closure: the size of the proposed space, safeAreaInsets and frame(in:) in the desired coordinate space (.local, .global, .named("scroll")). It is used when the layout depends on the available size: proportional columns, parallax, reading a position inside a ScrollView.

The rest of this answer, with code and interview follow-ups, is in the DevPrep app.

Read the full answer in DevPrep

Practice this before your interview

DevPrep turns these answers into one-minute challenges: what does this code print, find the bug, mock interviews. One challenge a day.

Get DevPrep on the App Store