0

这是我的代码,我正在尝试拖放一张将在 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];

}
4

3 回答 3

1

self.clipsToBounds = 否;是解决方案

于 2010-01-10T20:27:38.413 回答
0

将缩放模式设置为“中心”

于 2009-12-19T14:20:15.927 回答
0

哈哈,其实有一个简单的解决办法;只需设置 self.clipsToBounds = NO;

其中 self 代表 UIImageView

于 2009-12-19T16:45:39.007 回答