Ios UIViewanimation animationDidStop方法
我有一个8Ios UIViewanimation animationDidStop方法,ios,objective-c,uiview,uiimageview,uiviewanimation,Ios,Objective C,Uiview,Uiimageview,Uiviewanimation,我有一个8imagaviews,我用size(0,0)添加到我的视图中。现在我要做的是使用uiviewmanimation将每个图像视图依次拉出来。我想做两个动画。首先,大小应该从(0,0)-->(105,85)开始,完成后,imageview大小应该从(105,85)-->(93,75) 现在我有了一个方法,我首先将所有图像视图放置在正确的位置。所有图像都有size(0,0)在最后我调用该方法startAnimating -(void)startAnimating{ [self ani
imagaviews
,我用size(0,0)
添加到我的视图中。现在我要做的是使用uiviewmanimation
将每个图像视图依次拉出来。我想做两个动画。首先,大小应该从(0,0)-->(105,85)
开始,完成后,imageview大小应该从(105,85)-->(93,75)
现在我有了一个方法,我首先将所有图像视图放置在正确的位置。所有图像都有size(0,0)
在最后我调用该方法startAnimating
-(void)startAnimating{
[self animageButton:[arrButtons objectAtIndex:0]];
}
然后是第一个视图动画(从(0,0)-->(105,85))
这将调用第二个方法(从(105,85)-->(93,75))
现在,应该为第一个imageView设置动画。现在,当动画完成时。我同意这个
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
//do smth
if(loopIndex <= 7){
NSLog(@"called");
UIImageView *imgObj = [arrButtons objectAtIndex:loopIndex];
[self animageButton:imgObj];
}else{
NSLog(@"done");
return;
}
}
-(void)animationDidStop:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context{
//做smth
if(循环索引)
我尚未测试代码。如果有任何问题,请告诉我。谢谢。您真的应该使用自iOS 4.0以来出现的更新的动画方式([UIView animateWithDuration:animations:completion]
)。它有一个非常简单的方法在完成时运行动画。@Borrden这样做了。但现在动画从左上角开始。它们是在imageview的中心启动动画的方法吗?查看CALayer
的anchorPoint
属性。如果没有帮助,请发布新问题。
-(void)animageButton2:(UIImageView *)imgButton{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector: @selector(animationDidStop:finished:context:)];
CGRect btnFrame2 = imgButton.frame;
btnFrame2.size.width = 93;
btnFrame2.size.height = 75;
[UIView transitionWithView:self.view
duration:0.5f
options:UIViewAnimationOptionCurveEaseIn
animations:^{
imgButton.frame = btnFrame2;
}
completion:nil];
[UIView commitAnimations];
}
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
//do smth
if(loopIndex <= 7){
NSLog(@"called");
UIImageView *imgObj = [arrButtons objectAtIndex:loopIndex];
[self animageButton:imgObj];
}else{
NSLog(@"done");
return;
}
}
-(void)startAnimating
{
NSTimeInterval delay = 0.0;
for(UIImageView *imageView in arrButtons)
{
[self performSelector:@selector(animageButton:) withObject:imageView afterDelay:delay];
delay +=1.0;
}
}
-(void)animageButton:(UIImageView *)imgButton{
CGRect btnFrame = imgButton.frame;
btnFrame.size.width = 105;
btnFrame.size.height = 85;
[UIView animateWithDuration:0.5f animations:^{
imgButton.frame = btnFrame;
} completion:^(BOOL finished) {
[self animageButton2:imgButton];
}];
}
-(void)animageButton2:(UIImageView *)imgButton
{
CGRect btnFrame2 = imgButton.frame;
btnFrame2.size.width = 93;
btnFrame2.size.height = 75;
[UIView animateWithDuration:0.5f animations:^{
imgButton.frame = btnFrame2;
} completion:^(BOOL finished) {
}];
}