简体   繁体   中英

How to change background color of UIWebBrowserView in UIWebView in iOS8 Objective C

I wanna change UIColor of UIWebBrowserView in web view in iOS8 Objective C.
Please help me.
Thank you.

plz use this code

UIWebView * webView_article = [[UIWebView alloc]    initWithFrame:CGRectMake(0, 0, 200, 400)];
     webView_article.backgroundColor =yourClolor;

    webView_article.delegate=self;
    webView_article.scrollView.bounces = NO;
    webView_article.scrollView.showsVerticalScrollIndicator = NO;
    webView_article.scrollView.delaysContentTouches = NO;
    webView_article.scrollView.delegate = self;
    [webView_article setTag:11];
    [webView_article setOpaque:NO];

you have to set setOpaque to No

 UIWebView *web = [[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
 web.backgroundColor = [UIColor colorWithRed:32.0/255.0 green:32.0/255.0 blue:32.0/255.0 alpha:0.5];
 web.delegate=self;
 web.scrollView.bounces = NO;
 web.scrollView.showsVerticalScrollIndicator = NO;
 web.scrollView.delaysContentTouches = NO;
 web.scrollView.delegate = self;
 [web setOpaque:NO];

pragma -web view method

-(void)webViewDidStartLoad:(UIWebView *)webView{
    [SVProgressHUD showWithStatus:@"Loading..." ];
    [SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeClear];
    NSLog(@"start ...");
}
-(void)webViewDidFinishLoad:(UIWebView *)webView {

    [SVProgressHUD dismiss];    
    NSLog(@"finish");
}


-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {

    [SVProgressHUD dismiss];
    NSLog(@"Error for WEBVIEW: %@", [error description]);
}

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