这是我的代码,我正在尝试拖放一张将在 touchesBegan 上进行动画处理的卡片,但动画图像大于触摸开始之前的初始卡片图像。
如何更改 UIImageView 以适应 animateImages 大小?
cardAnimationArray 是一个包含 19 个图像 xxx1.png、xxx2.png... 的数组,它们有不同的大小。
cardMovedImage 是 19 张图像系列中的最后一张图像。先感谢您!!
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint pt = [[touches anyObject] locationInView:self.superview];
self.center = pt;
self.animationImages = [NSArray arrayWithArray:cardAnimationArray];
[cardAnimationArray release];
[self setAnimationRepeatCount:1];
self.animationDuration= 1;
[self startAnimating];
self.image = [UIImage imageNamed:cardMovedImageName];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event {
CGPoint pt = [[touches anyObject] locationInView:self.superview];
CGRect frame = [self frame];
frame.origin.x += pt.x - self.center.x;
frame.origin.y += pt.y - self.center.y;
[self setFrame: frame];
}