【问题标题】:Display the Image like Fade In using CABasicAnimation使用 CABasicAnimation 像 Fade In 一样显示图像
【发布时间】:2012-07-30 06:39:13
【问题描述】:

我正在使用 CABasicAnimation 顺时针旋转 Image 360​​,我使用的代码是

CALayer*    _caLayer = [CALayer layer];
_caLayer.contents = (id)_logo.CGImage;  
_caLayer.frame = CGRectMake(65,158, 180,55);
[self.view.layer addSublayer:_caLayer];
CABasicAnimation*   rotation;
rotation = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
rotation.fromValue = [NSNumber numberWithFloat:0];    
rotation.toValue = [NSNumber numberWithFloat:((360*M_PI)/180)];
rotation.duration = 1.4f;
//rotation.beginTime = CACurrentMediaTime() +1;
rotation.repeatCount = 2.0;
rotation.fillMode = kCAFillModeForwards;
[_caLayer addAnimation:rotation forKey:@"360"]; 

动画效果很好..但我无法弄清楚一件事。我想从较小的尺寸开始动画图像并以正常尺寸结束。你已经在电影中看到过,有些报纸会快速旋转并淡入,最后我们会在屏幕上完全看到报纸。我正在尝试这样做。我不知道该怎么做,拜托!

【问题讨论】:

    标签: iphone ios cocoa-touch calayer cabasicanimation


    【解决方案1】:

    你也可以使用下面的,就像一个魅力

    [UIView beginAnimations:@"fade in" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    _imageView.alpha = 0.0;
    _newImageView.alpha = 1.0;
    [UIView commitAnimations];
    

    【讨论】:

      【解决方案2】:

      设置动画前的imageView帧:[imageView setFrame: CGRectMake(your Frame)];

      然后继续使用循环或其他方式增加动画中的帧..

      【讨论】:

        猜你喜欢
        • 2011-08-26
        • 1970-01-01
        • 2015-12-14
        • 1970-01-01
        • 1970-01-01
        • 2023-03-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多