There was another post with this question but none of the solutions worked. My problem is that I have a couple of imageViews that I need to change the images of. It seems weird if I abruptly change them so I was wondering whether there was a way to fade the new image in.
This is when I set one of the imageViews.
self.imageView1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg", [images objectAtIndex:newArray[0]]]];
Thanks
Fading in an imageView can be achieved in multiple ways. If you could post your code, (how do you change the view without fading-in now) others will be able to suggest easiest approach
Edit: Try animating the alpha like in the code below:
self.imageView1.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg", [images objectAtIndex:newArray[0]]]];
self.imgView1.alpha=0;
[UIView animateWithDuration:2.0
delay:0.1
options: UIViewAnimationCurveLinear
animations:^{
self.imgView1.alpha=1;
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
You can control the values of animateWithDuration and delay to suit your app
Let us know if it works
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.