如何在iOS8中的UIWebView中更改UIWebBrowserView的背景颜色目标C.

时间:2016-10-01 10:47:22

标签: ios objective-c uiwebview uicolor

我想在iOS8 Objective C中的Web视图中更改UIWebBrowserView的UIColor 请帮帮我 谢谢。

2 个答案:

答案 0 :(得分:2)

使用此代码

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];

你必须将setOpaque设置为No

答案 1 :(得分:0)

 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视图方法

-(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]);
}