淡入查看 [英] fade View IN and OUT
问题描述
大家早上好
我对这个问题完全感到困惑。
I'm totally confused with this problem.
我有3个UIWebViews而应该发生的是webView1淡入(起作用)淡出和WebView2淡入......
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;
有人可以帮我吗?
当它在webView中消失时,即使背景颜色设置为其他颜色,它也会从白色逐渐消失!
我不能影响颜色吗?
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?
推荐答案
您应该使用 UIView
隐式动画。例如,从webView1到webView2的交叉淡入淡出:
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];
如果要在动画结束后执行一些代码,请将其插入begin和commit之间:
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:)];
并创建带有签名的didStop方法
and create the didStop method with the signature
- (void)fadeAnimationDidStop:(NSString*)animationID finished:(NSNumber*)finished context:(void*)context`
这篇关于淡入查看的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!