UIImageview Fade

时间:2014-09-22 12:44:12

标签: xcode uiimageview fade

当我点击我的按钮时,我试图让我的图像淡出并淡入。这段代码有问题吗?点击我的按钮后,我的图像仍然可见。

- (IBAction)Alpha:(id)sender {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    [UIView setAnimationDuration:2];
    _image.alpha = 1;
    [UIView commitAnimations];
    [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
  }
-(void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:2];
    _image.alpha = 0;
    [UIView commitAnimations];
}

1 个答案:

答案 0 :(得分:0)

您正在调用UIVIew上的方法,而不是您想要淡化的UIImageView实例上的方法。

你想要像

这样的东西
[self.myImageView beginAnimations....