简体   繁体   English

UIWebView尖角

[英]UIWebView sharp corners

I have an UIWebView with and using QuartzCore to add some style to this. 我有一个UIWebView并使用QuartzCore为此添加了一些样式。 But when i'm execute: 但是当我执行时:

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

I get an rounder View but content is sharp. 我得到了更全面的视图,但是内容很清晰。 There is a way to roundend corners in content in WebView 有一种方法可以消除WebView中内容的角落 在此处输入图片说明

内容视图实际上是UIWebViewscrollView ,因此

webView.scrollView.layer.cornerRadius = 10;

Agreed with @graver Answer but not completely Coz His working will not work on iphone 3g and iPod 2nd generation . 同意@graver Answer,但不完全同意Coz的工作将无法在iphone 3g和iPod 2nd generation上使用。

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

ClipsToBound will simple resize all the subviews under webView. ClipsToBound将简单地调整webView下所有子视图的大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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