fade View IN and OUT

你。 提交于 2019-12-12 01:19:04

问题


Good Morning everyone,

I'm totally confused with this problem.

I have 3 UIWebViews and what should hapen is webView1 fades in (that works) fades out und WebView2 fades in......

I made it so far with:

CATransition *Animation = [CATransition animation];
[Animation setDuration:4.0];
[Animation setType:kCATransitionFade];
[Animation setSubtype:kCATransitionFade];
[Animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];


transitioning = YES;

if (transitioning) {
    [self.webView1.layer addAnimation:Animation forKey:nil];
    self.webView1.hidden = YES;
    self.webView2.hidden = NO;

can anyone help me with that?

And when it fades in the webView fades from white even the background color is set to an other color! can't I effect the color?


回答1:


You should use UIView implicit animations. For instance, a cross fade from webView1 to webView2:

[UIView beginAnimations:@"fade" context:nil];
self.webView1.alpha = 0.0;
self.webView2.alpha = 1.0;
[UIView commitAnimations];

If you wanna execute some code after the animation finished, insert this between begin and commit:

[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(fadeAnimationDidStop:finished:context:)];

and create the didStop method with the signature

- (void)fadeAnimationDidStop:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context`



回答2:


transition.type =kCATransitionMoveIn;
transition.subtype =kCATransitionFade;


来源:https://stackoverflow.com/questions/4386038/fade-view-in-and-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!