开发者

IOS: set alpha in a UIImage

I have an UIImage and I want to set its alpha at 0.00 after 3 s开发者_运维百科econds... In my UIImage there is a picture that I want to immediately see when I go in a view, but after 3 second it must disappear.


Easy as that using core animation

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

if you dont want to slowly fade within 3 seconds, you can use

[UIView setAnimationDelay:3];

and reduce the animation duraction to 0.5f or something. i think using a short fade out time feels better than just simply set hide to YES


This will make it fade out within three seconds. Call from viewDidLoad:

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

Or if you want the animation to start at 2.5 seconds and last half a second, you could put that into a method (changing 3.0 to 0.5) and then call:

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


Are you showing your UIImage in a UIImageView?

If so, just set the hidden property on that image view to YES and the image view (with its image) will disappear.


You can always remove the sub-child view from the parent.

[imageView removeFromSuperview];

you can always add it later with

[self.view addSubview:imageView];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜