简体   繁体   中英

WebView with NSShadow slowdown

I have a webview that shows some animated boxes, but it slows down and lags horribly when I put a drop shadow in the view. Without the shadow, the webview contents animate smoothly.

I achieved a similar effect as safari/chrome when you do a elastic scroll with the touchpad. Looks nice. But doesnt run as smooth as in my inspirations.

Here is the snippet of the shadow setting:

NSShadow *dropShadow = [[NSShadow alloc] init];
[dropShadow setShadowColor:[NSColor blackColor]];
[dropShadow setShadowOffset:NSMakeSize(0, 0)];
[dropShadow setShadowBlurRadius:5.0];

[webview setWantsLayer: YES];
[webview setShadow: dropShadow];

[dropShadow release];

--

My question is: How can I work around this problem?

You should not call setWantsLayer:YES on a WebView . Layer-backed web views are unsupported. This was actually pointed out in the 10.5 release notes and has not changed, unfortunately. You'll need to come up with an alternative solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM