2012-05-22 63 views
1

我有一個UIWebView並使用QuartzCore爲其添加一些樣式。但是當我執行時:UIWebView銳角

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, self.view.bounds.size.width-20.0, self.view.bounds.size.height-30.0)]; 

NSString *urlAddress = @"http://www.google.com/"; 
NSURL *url = [NSURL URLWithString:urlAddress]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 
[webView loadRequest:requestObj]; 

webView.layer.cornerRadius = 10; 
webView.layer.borderColor = [UIColor whiteColor].CGColor; 
webView.layer.borderWidth = 3.0f; 
[self.view addSubview:webView]; 

我得到一個圓的視圖,但內容是銳利的。有一種方法來roundend中的WebView enter image description here

回答

5

內容角落內容畫面實際上是UIWebViewscrollView,所以

webView.scrollView.layer.cornerRadius = 10; 
+1

工程,太棒了!併爲我解決問題!感謝graver – Kuba

1

同意@graver的答案,但不能完全怎麼把他的工作將無法正常工作的iPhone 3G和iPod第二代。

webView.layer.cornerRadius = 10; 
[webView setClipsToBounds:YES]; 

ClipsToBound將簡單地調整webView下的所有子視圖。