2

On iOS, if we change a view's frame, we change its bounds, and if we change its bounds, we change its frame.

But we can change the internal coordinate system of a view by:

CGRect b = v.bounds;    // v is the UIView object
b.origin.x = 10000;
b.origin.y = 10000;
v.bounds = b;

and now, the top left point of the view is a coordinate of (10000, 10000). Is this also possible by merely changing frame and center but not bounds?

Jeremy L
  • 3,770
  • 6
  • 41
  • 62

1 Answers1

3

On iOS, if we change a view's frame, we change its bounds, and if we change its bounds, we change its frame.

That's half true. Only the sizes of those two rects are bound together. From the docs:

The size portion of the frame and bounds rectangles are coupled together so that changing the size of either rectangle updates the size of both.

That doesn't mention the origins. So your example will modify the internal coordinate system's origin without changing its position in the superview's coordinate system. You can't achieve that behavior via the frame or center properties; they only affect the the view's position in its superview's coordinate system.

Matt Wilding
  • 20,115
  • 3
  • 67
  • 95
  • To reiterate explicitly, they are _bound_, not _equal_. Rotations will cause interesting issues. See: http://stackoverflow.com/questions/5361369/ios-programming-frame-bounds-and-center – bshirley May 01 '13 at 16:38