我想做一个褪色的UIImageView使用不同的时代,让我们说,采用下列参数:

  • t=0...UIImageView的alpha=0
  • t=0.5秒...UIImageView的alpha=0.7
  • t=0.7s...UIImageView的alpha=0

这是可以做到的与CAAnimation或其他的方法?怎么可能做了什么?

感谢任何的帮助!

有帮助吗?

解决方案

你应该看看CAKeyframeAnimation.它会让你的设定值为多的时间点。

其他提示

if (imgDefault.alpha == 0.0) {
    CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration: 3.0];
        [UIView setAnimationDelegate: self];
        imgDefault.alpha = 1.0;
        [UIView commitAnimations];
}
else {
    CGContextRef context = UIGraphicsGetCurrentContext();
        [UIView beginAnimations:nil context:context];
        [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
        [UIView setAnimationDuration: 3.0];
        [UIView setAnimationDelegate: self];
        imgDefault.alpha = 0.0;
        [UIView commitAnimations];
}

希望它能帮助

)有setAnimationDidStopSelector:方法,该方法可以使用。简单地设置你的淡化在动画使用beginAnimations块,并设置的didStop选择另一种方法,它仅包含的淡出动画块。这些动画块可以有不同的动画的持续时间。

事情是这样的:

    [UIView beginAnimations:next context:context];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(fadeOut:finished:context:)];
    myView.alpha = 0.7;
    [UIView commitAnimations];

-(void)fadeOut:(NSString*)animationID finished:(BOOL)finished context:(void*)context  {
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationDuration:0.2];
    myView.alpha = 0.0;
    [UIView commitAnimations];
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top