Reputation: 135
let form = UIView(frame: CGRectMake(0.0, 140.0, view.bounds.width, 196))
print(form.bounds)
Prints: (0.0, 0.0, 375.0, 196.0)
Why is the Y origin returning 0.0?
Upvotes: 0
Views: 529
Reputation: 13679
Because you are printing form.bounds
instead of form.frame
The bounds rectangle is always relative to a view's own coordinate space, whereas the frame rectangle is relative to its superview's coordinate space. And a view's origin is always (0,0) relative to itself.
Upvotes: 1