IOS: set alpha to UIImage

I have a UIImage and I want to set its alpha to 0.00 after 3 seconds ... In my UIImage there is an image that I want to see immediately when I go to the point of view, but after 3 seconds it should disappear.

+6
source share
4 answers

Easy as using basic animation

[UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:3.0f]; imageView.alpha = 0.0f; [UIView commitAnimations]; 

If you do not want to fade out within 3 seconds, you can use

 [UIView setAnimationDelay:3]; 

and reduce the duration of the animation arc to 0.5f or something else. I think using a short decay time is better than just setting hide on YES

+10
source

This will make it disappear within three seconds. A call from viewDidLoad:

 [UIView animateWithDuration:3.0 animations:^{myImage.alpha = 0; }]; 

Or, if you want the animation to start in 2.5 seconds and the last half second, you can apply it to the method (with changes from 3.0 to 0.5), and then call:

 [NSTimer scheduledTimerWithTimeInterval:2.5 target:self selector:@selector(hideMyImage) userInfo:nil repeats:no]; 
+5
source

Are you showing your UIImage in a UIImageView ?

If so, simply set the hidden property in this image view to YES, and the image (with its image) will disappear.

+1
source

You can always remove the representation of a child of a child from a parent.

 [imageView removeFromSuperview]; 

you can always add it later

 [self.view addSubview:imageView]; 
0
source

Source: https://habr.com/ru/post/897699/


All Articles