Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/106.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 在Xcode中裁剪UIWebView_Ios_Xcode_Uiwebview - Fatal编程技术网

Ios 在Xcode中裁剪UIWebView

Ios 在Xcode中裁剪UIWebView,ios,xcode,uiwebview,Ios,Xcode,Uiwebview,我有一个UIWebView,但不想在页面顶部显示任何东西,低至大约50像素。我需要一种裁剪UIWebView的方法,这样用户就看不到超过50像素边距的内容。如何有效地执行此操作?UIWebview包含用于显示HTML内容的UIScrollView。更改内容offset允许更改页面视图。。。参见谷歌的例子 /** * basic webview boilerpoint */ UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRec

我有一个UIWebView,但不想在页面顶部显示任何东西,低至大约50像素。我需要一种裁剪UIWebView的方法,这样用户就看不到超过50像素边距的内容。如何有效地执行此操作?

UIWebview包含用于显示HTML内容的UIScrollView。更改内容offset允许更改页面视图。。。参见谷歌的例子

/**
 *  basic webview boilerpoint
 */
UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,
                                                                 0,
                                                                 CGRectGetWidth(self.view.frame),
                                                                 CGRectGetHeight(self.view.frame))];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.co.uk"]]];
[self.view addSubview:webView];

/**
 *  disable bounces so users cannot scroll beyond content & set top offset by 100 to hide parts of website
 */
webView.scrollView.bounces = NO;
webView.scrollView.contentInset = UIEdgeInsetsMake(-100, 0, 0, 0);

只需将背景颜色为白色或黑色的视图放置在webview顶部,并将其高度设置为50。但当用户拖动下方时,他可以看到,他只能看到,直到拖动为止,当他释放拖动时,它将看不到visible@hardikhadwani谢谢你的回复,但是有没有办法让用户看不到上面的内容,即使他拖动?UIWebView是..的子类。。更新内容偏移量应该可以解决您的问题