-1

I have an imageView background which changes on swipes. Currently it changes instantly, but can I use a fade effect so that the next image fades into view?

I have found some results when searching, but mostly in Java

  • I searched further and found this: http://stackoverflow.com/questions/7638831/fade-dissolve-when-changing-uiimageviews-image So I will delete this question – user3649561 May 18 '14 at 18:46

1 Answers1

0

I am guessing you are using a swipe gesture on your imageView to change the image when the swipe happens.

So in the target method of your swipe gesture where you are currently changing the image, Set an animation block to do your animation, something like this

[UIView animateWithDuration:1.0 animations:^{
          imageview.alpha = 0.0;

 } completion:^(BOOL finished) {

     imageview.image = newImage;
     [UIView animateWithDuration:1.0 animations:^{
         imageview.alpha = 1.0;

     }];

}];

This is the a simpler way to achieve this , hope this helps. Cheers !

NavinDev
  • 995
  • 1
  • 7
  • 8
  • Hey Navin, thanks! I have already found another solution that works pretty good. But can I use your method on my label instead? This also changes on swipe, though the opposite direction swipe - so therefore not exactly same function @NavinDev – user3649561 May 18 '14 at 19:26
  • I guess you could , any property changes such as alpha , frame etc changes in an animation block will progress slowly to the new value . and since UIlabel too has these properties you could use them. – NavinDev May 18 '14 at 19:41