开发者

ObjC: Moving the displayed area of a UIView

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

currently the left part is shown (that is (0,0,480,320)) 开发者_JAVA技巧and I would like to be able to show the right side on click. I tried to change the UIView's frame to (480,0,905,320) but it does not seem to work.

Does anyone know how to do it?

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


You want to set the bounds of your view, not the frame. More specifically, the origin of it's bounds determines the offset for where the view's content should start displaying. That way the view doesn't move at all, just reveals a different chunk of it's content.

The documentation shows this very clearly:

See "The Relationship of the Frame, Bounds, and Center" View Programming Guide for iPhone


When you change the view's frame, you're moving the view, not the part that's displayed. So you should use (-480, 0, 905, 320).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜