如何连续几次对 UIImageView 旋转进行动画处理
我正在尝试为 UIImage 视图设置动画,每次顺时针旋转 90 度。 由于某种原因,第一个旋转动画有效,但随后停止(即使其他视图调整大小动画继续工作)。这是为什么? (我到处找但找不到答案)
{
[btn setFrame:CGRectMake(previousX, previousY, BUTTON_WIDTH, BUTTON_HEIGHT)];
[self.view insertSubview:btn atIndex:0];
[UIView beginAnimations:@"ButtonAnimation" context:nil];
[UIView setAnimationDuration:2.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGRect rect = CGRectMake(previousX,previousY+BUTTON_HEIGHT,BUTTON_WIDTH,BUTTON_HEIGHT);
btn.frame = rect;
[UIView setAnimationBeginsFromCurrentState:YES];
++ButtonCounter;
if (ButtonCounter < [btnArray count])
{
[UIView setAnimationDidStopSelector:@selector(didStopReal)];
}
else
{
ButtonCounter = 0;
}
// The transform matrix
CGAffineTransform transform =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90));
imgArrowView.transform = transform;
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
-(void) didStopReal
{
[self animteReal:ButtonCounter];
}
I'm trying to animate an UIImage view, each time by 90 degree clockwise.
For some reason, the first rotation animation works, but then it stops (even though the other view resizing animation continue to work). Why is that? (I looked everywhere but couldn't find an answer)
{
[btn setFrame:CGRectMake(previousX, previousY, BUTTON_WIDTH, BUTTON_HEIGHT)];
[self.view insertSubview:btn atIndex:0];
[UIView beginAnimations:@"ButtonAnimation" context:nil];
[UIView setAnimationDuration:2.5];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
CGRect rect = CGRectMake(previousX,previousY+BUTTON_HEIGHT,BUTTON_WIDTH,BUTTON_HEIGHT);
btn.frame = rect;
[UIView setAnimationBeginsFromCurrentState:YES];
++ButtonCounter;
if (ButtonCounter < [btnArray count])
{
[UIView setAnimationDidStopSelector:@selector(didStopReal)];
}
else
{
ButtonCounter = 0;
}
// The transform matrix
CGAffineTransform transform =
CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(90));
imgArrowView.transform = transform;
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
-(void) didStopReal
{
[self animteReal:ButtonCounter];
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
构建相对于当前变换的变换矩阵:
Build your transform matrix relative to the current transform: