gpt4 book ai didi

ios - 在 Xcode 中裁剪 UIWebView

转载 作者:行者123 更新时间:2023-11-28 21:55:36 24 4
gpt4 key购买 nike

我有一个 UIWebView,但不想在页面顶部显示任何东西,低至大约 50 像素。我需要一种裁剪 UIWebView 的方法,以便用户看不到 50 像素边距以上的内容。我怎样才能有效地做到这一点?

最佳答案

UIWebview 包含一个用于显示 HTML 内容的 UIScrollView。更改内容偏移量允许更改页面 View ...请参阅 google 示例

/**
* 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);

关于ios - 在 Xcode 中裁剪 UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26709219/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com