I use a web view to display small pdf files. In the interest of aesthetics, I'd like to remove the grey border around the PDF. Is there any way around it? I've looked at various resources none of which seem to work or the solution no longer works in iOS5.
Also, is there any way of stopping the scroll if there's only one page?
Thanks.
The shadows are actually UIImageView subviews of the UIScrollView (or the equivalent in iOS5 UIWebView).
So in iOS4:
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];
}
}
}
}
and in iOS5 and above:
for (UIView* shadowView in [webView.scrollView subviews])
{
if ([shadowView isKindOfClass:[UIImageView class]]) {
[shadowView setHidden:YES];
}
}
Works great with iOS 9
- (void)webViewDidFinishLoad:(UIWebView *)webView {
for (UIView *object in webView.scrollView.subviews) {
if ([NSStringFromClass([object class]) isEqualToString:@"UIWebPDFView"]) {
UIView *pdfView = object;
for (UIView *pdfObjectSubview in pdfView.subviews) {
if ([NSStringFromClass([pdfObjectSubview class]) isEqualToString:@"UIPDFPageView"]) {
UIView *uiPDFPageView = pdfObjectSubview;
uiPDFPageView.layer.shadowOpacity = 0.0f;
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With