Member-only story

The Coordinate System: iOS and Swift

The view coordinate system is really important

5 min readJan 4, 2021

--

Photo by Tim Marshall on Unsplash

Difficulty: Beginner | Easy | Normal | Challenging

Prerequisites:

The View coordinate system

The Units and structs used

CGFloat: A floating point number used for graphics
CGPoint: A C struct containing two CGFloats
CGRect: A C struct with an origin and a size (both of which are representated as a CGSize). Can be initialised with CGRect(origin:, size:) or CGRect(x: 0, y: , width: , height: ) . The origin is represented as a CGPoint.
CGSize: A C struct with a width and height.

The origin

The origin of any particular view is in the upper-left hand corner

The origin for a view

That is, the origin could be represented by a let origin = CGPoint(x: 0, y: 0) (which is actually the origin shown in the…

--

--

Responses (3)

Write a response