How to crossfade between 2 images on iPhone using Core Animation

后端 未结 6 503
既然无缘
既然无缘 2020-11-30 18:38

I\'m doing this to learn how to work with Core Animation animatable properties on iPhone (not to learn how to crossfade images, per se).

Reading similar questions on

6条回答
  •  抹茶落季
    2020-11-30 19:24

    I found this somewhere - it works great.

    Swift

    UIView.transition(with: imageView, duration: 0.33, options: .transitionCrossDissolve, animations: {
          imageView.image = image
    }, completion: nil)
    

    Objc

    UIImage * toImage = [UIImage imageNamed:@"image.png"];
    [UIView transitionWithView:self.view
                      duration:0.33f
                       options:UIViewAnimationOptionTransitionCrossDissolve
                    animations:^{
                        self.imageview.image = toImage;
                    } completion:NULL];
    

提交回复
热议问题