Sitemap

Member-only story

Advanced Swift: CGPoint

Learn about CGPoint in Swift and SwiftUI

5 min readMay 21, 2025

--

Press enter or click to view image in full size

Imagine for a moment you’re building an app called SneakerScope. A digital map where sneakerheads can pin rare drops around the city. You want to show a glowing Jordan 1 marker exactly at the corner of “Nostalgia Avenue” and “Just Dropped Blvd.” But how do you tell Swift where to place that little badge of hype?

Enter CGPoint. It's not glamorous. It doesn’t animate. It won’t fetch you data or organize your views. But without it, nothing appears where it's supposed to. CGPoint is the singular hero of all 2D positioning in iOS. Let’s unpack what makes this tiny struct one of the most fundamental building blocks in your UI kit.

Storytime: The Coordinates of Cool

Back to our SneakerScope app…you’ve got a custom SneakerPinView, and you want to drop it onto a map at the exact spot where someone reported a pair of Travis Scott 6s for retail.

A CGPoint simply stores two things: an x-value and a y-value.

Press enter or click to view image in full size

This point means: move 120 points to the right and 300 points down from the top-left corner of the screen.

--

--

Stanley Miller 
Stanley Miller 

Written by Stanley Miller 

iOS Developer. Author. Fan of the interesting. Written 100+ Swift/SwiftUI articles.