Skip to content

SwiftUI: GeometryReader

Last updated on February 27, 2020

With GeometryReader, it gives you the important information that you need such as height, width and safe area insets. With information like this, you will be able to set the size of the view on any devices.

A container view that defines its content as a function of its own size and coordinate space.

Apple Documentation

In this tutorial, you’ll learn what it takes to build a GeometryReader in SwiftUI. You’ll learn:

  • How to build a GeometryReader from scratch.


To follow along this tutorial, you’ll need some basic knowledge in:

  • A basic familiarity with Swift.
  • At least Xcode 11


To begin with GeometryReader, you will begin by placing a Circle around it to reflect the easiness of placing a view anywhere by giving a x & y coordinate.

GeometryReader Width & Height

First, you will get the width and the height of the GeometryReader

GeometryReader x & y Coordinates

To get the x and y coordinates, you can use the following code.

And this include minimum, mid and max as well. Depending on your need, you may retrieve the minimum X with the following.

GeometryReader Safe Area Inset

Safe area of the view can be retrieved as follow:

Where to go From Here

If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created:

Published inSwiftUI

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *