开发者

iPad - How to move Mulitple UIViews side-by-side

How to move multiple UIViews Side-by-Side just like a开发者_运维百科n twitter application working in iPad. With full of effects animation and rotations.


You should take a look at the UIScrollView with paging enabled.

Make all your views and put them next to one another inside a UIScrollView. i.e.

// Get your views
MyView *v1 = [[[MyView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
MyView *v2 = [[[MyView alloc] initWithFrame:CGRectMake(320, 0, 320, 480)] autorelease];
MyView *v3 = [[[MyView alloc] initWithFrame:CGRectMake(640, 0, 320, 480)] autorelease];

// Make the UIScrollView
UIScrollView *scroll = [[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)] autorelease];
[scroll setPagingEnabled:YES];
[[scroll addSubview:v1];
[[scroll addSubview:v2];
[[scroll addSubview:v3];
[scroll setContentSize:CGSizeMake(960, 480)];

// add the scroll view to your view
[[self view] addSubview:scroll];

Now, the three views (v1, v2 and v3) are next to each other in a scroll view whose content is much wider the view. With paging enabled, they will scroll left and right but won't stop halfway through a view.


Take a look at view animations:

http://www.switchonthecode.com/tutorials/creating-basic-animations-on-iphone

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜