Frame vs bounds in Swift



1, Frame

The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width, height) relative to the superview it is contained within.

In short, a view's location and size using the parent view's coordinate system


2, Bounds

The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width, height) relative to its own coordinate system (0,0).

 In short, a view's location and size using its own coordinate system

Example:


Frame
    origin = (40, 60)
    width = 80
    height = 130

Bounds 
    origin = (0, 0)
    width = 80
    height = 130


Thanks for reading, Happy Coding 👨‍💻 

Popular posts from this blog

Show image in Flutter

CustomStringConvertible in Swift

Property wrapper in Swift