【问题标题】:two UIView Animation on the same image同一图像上的两个 UIView 动画
【发布时间】:2011-11-05 18:16:04
【问题描述】:

我想在同一张图片上用同样的方法制作两个 UIView 动画:

-(void)likeThis{
[UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.75];
        [UIView setAnimationDelegate:self];
        image.alpha=0;
        [UIView commitAnimations];

    [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.75];
        [UIView setAnimationDelegate:self];
        image.transform = CGAffineTransformScale(5,5);
        [UIView commitAnimations];

}

但是这些 UIView 动画中只有一个可以工作。我不知道为什么。我认为还有另一种方法可以为同一个图像放置两个动画,但我不知道如何。对不起我的英语我是法国人:/

【问题讨论】:

    标签: iphone xcode animation methods uiimageview


    【解决方案1】:

    你可以把它们放在同一个动画块中:

    -(void)likeThis
    {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.75];
        [UIView setAnimationDelegate:self];
        image.alpha=0;
        image.transform = CGAffineTransformScale(image.transform,5,5);
        [UIView commitAnimations];
    }
    

    请注意,CGAffineTransformScale 需要三个参数:

    CGAffineTransformScale(image.transform, 5.0, 5.0)

    http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html#//apple_ref/doc/uid/TP30000946-CH1g-F16985

    或者你可以使用 CGAffineTransformMakeScale: http://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGAffineTransform/Reference/reference.html#//apple_ref/c/func/CGAffineTransformMakeScale

    【讨论】:

      【解决方案2】:

      您希望它们同时发生还是一个接一个地发生?如果前者只是将它们都包含在一组 beginAnimations..commitAnimations 调用之间

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2023-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多