【发布时间】:2014-03-17 17:37:30
【问题描述】:
)) 我正在尝试对 UIButton 进行动画处理(两个并行动画:图像的变化和移动),如下所示,动画按钮应该移动后,但完成动画按钮后会转到开始位置。请帮忙解决!提前致谢!
- (IBAction)bugOneTapped:(id)sender
{
[UIView animateWithDuration:1.0
animations:^{
self.bugOneButton.imageView.animationImages =
[NSArray arrayWithObjects:[UIImage imageNamed:@"bugOne3"],[UIImage imageNamed:@"bugOne2"],[UIImage imageNamed:@"bugOne1"],[UIImage imageNamed:@"bugOne2"],[UIImage imageNamed:@"bugOne3"],[UIImage imageNamed:@"bugOne4"],[UIImage imageNamed:@"bugOne5"],[UIImage imageNamed:@"bugOne4"],nil];
self.bugOneButton.imageView.animationDuration = 0.3;
[self.bugOneButton.imageView startAnimating];
self.bugOneButton.center = CGPointMake(self.bugOnePositionX, self.bugOneButton.center.y - 50);
self.bugOnePositionY = self.bugOnePositionY - 50;
}completion:^(BOOL finished) {
[self.bugOneButton.imageView stopAnimating];
}];
self.bugOneButton.center = CGPointMake(self.bugOnePositionX, self.bugOnePositionY);
}
【问题讨论】:
-
您在完成块之后再次将中心设置为初始位置..
-
移除这个 self.bugOnePositionY = self.bugOnePositionY - 50;
-
谢谢,上面的Y位置改了,为什么没改?
标签: ios objective-c animation uiviewanimation