Pug*_*gal 5 iphone animation uiview
如何从左到右动画视图过渡(类似推视图).单击按钮时,视图应从左向右移动.所以请指导我并给出一些示例链接.
谢谢.
假设你想从右边推view2来替换view1。
// Set up view2
view2.frame = view1.frame;
view2.center = CGPointMake(view1.center.x + CGRectGetWidth(view1.frame), view1.center.y);
[view1.superview addSubview: view2];
// Animate the push
[UIView beginAnimations: nil context: NULL];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector: @selector(pushAnimationDidStop:finished:context:)];
view2.center = view1.center;
view1.center = CGPointMake(view1.center.x - CGRectGetWidth(view1.frame), view1.center.y);
[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)
然后(可选)实现此方法以从视图层次结构中删除 view1:
- (void) pushAnimationDidStop: (NSString *) animationID finished: (NSNumber *) finished context: (void *) context {
[view1 removeFromSuperview];
}
Run Code Online (Sandbox Code Playgroud)
在该动画委托方法中,您可能还想释放 view1 并将其引用设置为 nil,具体取决于您是否需要在转换后保留它。
| 归档时间: |
|
| 查看次数: |
4418 次 |
| 最近记录: |