Search code examples
iphoneuiviewframebounds

Custom UIView with smaller bounds than frame


Is it possible to create a custom uiview (loaded from a nib) with bounds smaller than the frame. So I would like to show a part of the frame/view. On a button press I want to slide the bounds to the right to see the whole frame. Can this be done?


Solution

  • A view's bounds represents the bounding rectangle in the view's own coordinate system. The frame is the bounding rectangle in the superview's coordinate system. By changing a view's transform, you could easily create a bounds rectangle with origin={0, 0} and size={1, 1}, even though the view's frame was origin={0, 0}, size={320, 480}. That view might cover the entire screen, but the bounds is still only 1 unit by 1 unit in size.

    I see what you're trying to do, and that's really a different thing from bounds != frame. You're talking about having a content view that's only partially visible through an enclosing view. This is exactly what UIScrollView does for you.