1

我使用 UIView 的动画功能(例如 [UIView animateWithDuration:]、[UIView beginAnimations] ... [UIView commitAnimations])开发了一个应用程序。当我在 iPad 上调试它时,它运行正常,但是在服务器几个小时后,动画突然变得非常快,它的持续时间比它的持续时间短。我想知道发生了什么,我不知道。谁能帮我吗?使用的代码 1

[UIView beginAnimations:@"showShine" context:view];
[UIView setAnimationDidStopSelector:@selector(animFinished:finished:context:)]; 
[UIView setAnimationDelegate:self]; 
[UIView setAnimationDuration:0.4f]; 
view.frame = CGRectMake(center.x - F_WIDTH / 2, center.y - F_HEIGHT / 2, F_WIDTH, F_HEIGHT); [self.view addSubview:view]; 
[UIView commitAnimations];

使用的代码 2

[UIView animateWithDuration:DURIATION 
animations:^{ 
[aniView setFrame:rtDestAfter]; 
} 
completion:^(BOOL finised){ 
[self animationFinished:stoken]; 
[stoken release]; 
} 
]; 

谢谢。

4

1 回答 1

0

为此目的使用块代码

animateWithDuration:animations:completion

例如

[UIView animateWithDuration:0.2
     animations:^{view.alpha = 0.0;}
     completion:^(BOOL finished){ [view removeFromSuperview]; }];

或者

+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion

编辑

无论如何在动画块中添加子视图方法是什么。首先在块外/之前添加具有适当帧的子视图并在动画块内实现动画

于 2013-05-08T09:12:10.927 回答