在我的iOS应用中,我正在尝试同时执行2个动画。但是,下面的代码不能满足我的要求。它取消了第一个动画,只取消了第二个动画(来自通知的动画)。至于第一个就在1秒之后才到达最终结果。
dispatch_async(dispatch_get_main_queue(), ^ {
CGRect tempRect = CGRectMake(0, self.view.frame.size.height, toolbar.frame.size.width, toolbar.frame.size.height);
[UIView animateWithDuration: 1.0f
animations: ^ {
toolbar.frame = tempRect;
}
completion: ^ (BOOL finished) {
[toolbar setHidden: YES];
isPlayerToolbarActive = NO;
}];
});
[
[NSNotificationCenter defaultCenter] postNotificationName: @"animateSidePanels"
object: @"removingPlayerToolbar"];
// notification is sent here
-
(void) animateSidePanels: (NSNotification * ) notification {
if ([notification.object isEqualToString: @"removingPlayerToolbar"]) {
[self.interactionsViewController performExtendAnimation: self.interactionsViewController.view.frame.size.height + 44
withDuration: 1.0f
completion: ^ (BOOL finished) {
}];
}
}
-(void)performExtendAnimation:(CGFloat)newHeight withDuration:(CGFloat)duration completion:(void (^)(BOOL finished))completion
{
[UIView animateWithDuration:duration animations:^{
CGRect newFrame = CGRectMake(self.view.frame.origin.x,
self.view.frame.origin.y,
self.view.frame.size.width,
newHeight);
self.view.frame = newFrame;
}completion: completion];
} 任何形式的帮助都非常感谢!
答案 0 :(得分:2)
尝试使用UIView
的{{1}}方法,并在选项中提供animateWithDuration:delay:options:animations:completion:
和UIViewAnimationOptionBeginFromCurrentState
。
答案 1 :(得分:1)
要为interactionViewController
的扩展动画制作动画,请使用方法:
+[UIView animateWithDuration:delay:options:animations:completion:]
选项UIViewAnimationOption
AllowAnimatedContent
。