Remove gradient background from UIWebView?(从 UIWebView 中删除渐变背景?)
问题描述
如何从 UIWebView 中移除渐变 - 如果您过度滚动顶部或底部,您会看到渐变.这段代码
How do remove the gradient from a UIWebView - the one that you see if you overscroll the top or bottom. This code
webView.backgroundColor = [UIColor whiteColor];
只是改变渐变的颜色,并不会移除它.如何做到这一点?
just changes the color of the gradient, it doesn't removes it. How can this be done?
(注意:与UIWebView underside的问题不同)
(note: not the same question as UIWebView underside)
推荐答案
啊哈,是的,术语失败了.我根本不会称它为影子,但 c'est la vie.这是我实现效果的类型安全代码.总结一下:这将隐藏滚动视图的任何图像视图子项.它不像 (objectAtIndex:0) 方法那样容易受到更改,因此如果 Apple 重新排序 webView 控件的子项,它将正常工作,但仍然依赖于渐变效果由父级到滚动的图像视图应用的事实视图(并且确实有一个支持 Web 视图的滚动视图).
Aha, yes terminology fail. I wouldn't call that a shadow at all, but c'est la vie. Here is my type-safe code to achieve the effect. To summarise: this will hide any image-view children of the scroll view. It's not as vulnerable to change as the (objectAtIndex:0) methods, so if Apple re-order the children of the webView control it will work fine, but still relies on the fact that the gradient effect is applied by imageviews parented to the scroll view (and that there is indeed a scrollview underpinning the web view).
{
webView.backgroundColor = [UIColor whiteColor];
for (UIView* subView in [webView subviews])
{
if ([subView isKindOfClass:[UIScrollView class]]) {
for (UIView* shadowView in [subView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
}
}
}
这篇关于从 UIWebView 中删除渐变背景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 UIWebView 中删除渐变背景?
- 使用自动布局向 UIScrollView 添加动态大小的视图 2022-01-01
- 如何在 iPhone 模拟器中重置 NSUserDefaults 数据? 2022-01-01
- 网上有没有好的 UIScrollView 教程? 2022-01-01
- 类似于 Mail.app 的 iPad 模态视图控制器? 2022-01-01
- UITextView 内容插图 2022-01-01
- URL编码Swift iOS 2022-01-01
- Xcode 7.3 中带有 UILabel 的 UIStackView 2022-01-01
- SetOnItemSelectedListener上的微调程序错误 2022-01-01
- 在 Iphone SDK 的导航栏上添加多个按钮 2022-01-01
- GPS状态的广播接收器? 2022-01-01