Reputation: 540
What is the difference between bounds.size.width
and bounds.width
in swift? Will they return the same thing?
Thanks!
Upvotes: 4
Views: 4442
Reputation: 6704
bounds
is a CGRect
struct property for a UIView that contains 2 nested structs within it; CGPoint
and CGSize
. These represent the points of origin for the view (x and y), and the size of the view in height and width specified in points respectively.
If you have a UIView that's 100 x 100, then: bounds.width
will return 100, and bounds.size.width
will also return 100. Basically they will return the same CGFloat
values even if your CGRect
has negative width and height values.
Upvotes: 7