开发者

Fade in/out a WebView

my problem might be simple but the solution escapes me.

I have a WebView embeded in a NSView, and loaded with some content. I'd like to add a simple fade transition (upon a button click) which after 2 seconds just dissapears and the WebView simply shows again the original content.

I dont know if I can do this in the WebView itself through Interface Builder, or I need to user layers and CATransitions programmatically.

So far I have tried different variations of this:

[m_pView setWantsLayer:YES];开发者_开发百科

CATransition *transition = [CATransition animation];

transition.duration = 2;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionFade;

[ [m_pView layer] addAnimation:transition forKey:nil];  

All I got is erasing the original content from the View and replace it with a blank. I suppose Im using the layers incorrectly, and maybe they arent needed at all to solve my problem.

Anyone can help me with this?


Using a WebView on a layer-backed view is not supported. This is only outlined in the Leopard release notes but it's still the case in 10.6.

You'll need to do some juggling to get this to work, most probably by swapping the WebView with an NSImageView containing a screenshot of the WebView contents, fading that and then swapping the WebView back in with its new content.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜