自动淡入xcode中的图像

时间:2012-10-01 17:14:41

标签: uiimage xcode4.3 nstimer

您好我可以自动淡化图像。如何自动淡化图像IN。

这是我的代码。

·H

@property (assign) IBOutlet UIImageView *cbizFadeImage;

的.m

- (void)viewDidLoad {
//Fade Image Out
CGRect aboutNicheImageFrame = cbizFadeImage.frame;
aboutNicheImageFrame.origin.y = self.view.bounds.size.height;


// iOS4+
[UIView animateWithDuration:0.5
                      delay:2.0
                    options: UIViewAnimationCurveEaseOut
                 animations:^{
                     cbizFadeImage.alpha = 0;

                 }
                 completion:^(BOOL finished){
                     NSLog(@"Done!");
                 }];
}

好的我可以通过将CurveEaseOut更改为CurveEaseIn来淡化图像。但是现在我想把图像淡出来。因此,图像将首先缓和然后它会缓和。我会使用if语句吗?

3 个答案:

答案 0 :(得分:0)

我能够使用UIViewAnimationCurveEaseInOut。

答案 1 :(得分:0)

使用此选项代替UIViewAnimationCurveEaseInOut:

options:UIViewAnimationOptionCurveEaseOut

答案 2 :(得分:0)

我觉得你真正要求的是UIViewKeyframeAnimationOptionAutoreverse像这样使用......

Image.alpha = 0;
[UIView animateKeyframesWithDuration:5.0 delay:0.0        options:UIViewKeyframeAnimationOptionAutoreverse |     UIViewKeyframeAnimationOptionRepeat animations:^{
[UIView addKeyframeWithRelativeStartTime:0.9 relativeDuration:0.0     animations:^{
Image.alpha = 1;
}];
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0     animations:^{
Image.alpha = 0;
}];
} completion:nil];
相关问题