ObjC: moving the display area of ​​a UIView

I have a big UIView ( .frame == CGRectMake(0, 0, 905, 320) )

the left side is currently shown (this is (0,0,480,320) ), and I would like to be able to show the right side by click. I tried changing the UIView frame to (480,0,905,320) , but it doesn't seem to work.

Does anyone know how to do this?

it is embedded in the window with .frame == (0, 0, 480, 320) . All in landscape mode.

+4
source share
2 answers

You want to set the boundaries of your view, not the frame. More specifically, the start of its borders determines the offset for where the contents of the view should be displayed. Thus, the view does not move at all, it just shows another piece of this content.

The documentation shows this very clearly:

See β€œLink Frame, Border, and Center.” View iPhone Programming Guide

+3
source

When you change the view frame, you move the view, not the part that is displayed. Therefore, you should use (-480, 0, 905, 320).

0
source

All Articles