简体   繁体   中英

How to set clear UIWebView Background?

I am trying to set the clear background of web view, but i could not found anything for this issue, so please help me, so How will i remove gradient background and make UIWebview transparent?

Thanks

To make UIWebView Background transparent you may use

webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];

If you also want to remove shadows create Category for UIWebView:

UIWebView+ShadowRemoval.m

#import "UIWebView+ShadowRemoval.h"

@implementation UIWebView (ShadowRemoval)

-(void)removeShadows
{
    for(UIView *view in [self subviews] ) {
      if( [view isKindOfClass:[UIScrollView class]] ) {
         for( UIView *innerView in [view subviews] ) {
            if( [innerView isKindOfClass:[UIImageView class]] ) {
                innerView.hidden = YES;
            }
        }
     }
  }
}

@end

Please try this snippet code with your web view

myWebView.opaque = NO; [myWebView setBackgroundColor:[UIColor clearColor]];

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