0
UIImageView *image = [[UIImageView alloc] initWithFrame:self.view.bounds];
        image.animationImages = [NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"BluePin.png"],
                                 [UIImage imageNamed:@"GreenPin.png"],
                                 [UIImage imageNamed:@"RedPin.png"],
                                 [UIImage imageNamed:@"YellowPin.png"],
                                 nil];

        image.animationRepeatCount = 0;
        image.animationDuration = 1.0;
        [image startAnimating];

        [image setFrame: CGRectMake(point.x-(image.bounds.size.width/2), point.y-            (image.bounds.size.width/2), image.bounds.size.width, image.bounds.size.height)];
        [self.view addSubview: image];



        [UIView animateWithDuration:2.0 delay:1.0    options:UIViewAnimationOptionCurveLinear  animations:^{
            [image setAlpha:0.0];
        } completion:^(BOOL finished) {
            [image removeFromSuperview];

        }];

图像出来的太大了,它们需要保持原始大小基本上会在用户触摸的地方创建图像动画,并在 x 秒后消失

4

1 回答 1

0

您希望图像视图与其包含的图像具有相同的尺寸,对吗?

UIImage *image = [UIImage imageName:@"BluePin.png"];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,image.size.width,image.size.height];

请注意,我使用与您不同的变量命名方案来区分图像和图像视图。

于 2012-09-16T22:06:46.140 回答