//
//  BGPlainWebView.h
//  BGPlainWebView
//
//  Created by Geri on 2/23/11.
//  Copyright 2011 ©ompactApps. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface BGPlainWebView : UIWebView
{
	UIColor *backgroundColor;
}
@property (nonatomic, retain) UIColor *backgroundColor;

@end

//
//  BGPlainWebView.m
//  BGPlainWebView
//
//  Created by Geri on 2/23/11.
//  Copyright 2011 ©ompactApps. All rights reserved.
//

#import "BGPlainWebView.h"

@implementation BGPlainWebView
@synthesize backgroundColor;

-(id)initWithCoder:(NSCoder*) coder
{
    if(self = [super initWithCoder:coder])
	self.backgroundColor = [UIColor whiteColor];
	
	return self;
}  

-(void)layoutSubviews
{
	NSLog(@"layoutSubviews");
	
	//Set the webView's background.
	[[[self subviews] lastObject] setBackgroundColor:backgroundColor]; 
	
	//Hide shadow (hide every UIImageView instance).
	for(UIView *eachSubview in [[[self subviews] objectAtIndex:0] subviews])
	if ([eachSubview isKindOfClass:[UIImageView class]] && eachSubview.frame.size.width >= 320.0) eachSubview.hidden = YES;
}

@end

In my recent project I have to embed some UIWebView into a complex view hierarchy where the gray background and the shadows at the bounce area of the UIWebView are disturbing the UI.

So I subclassed UIWebView and gently hide the shadow, and configure the background color. Hope Apple won't mind it, I tried to involve many test before hide the shadow.

Though, a code piece like this makes the whole bundle more breakable. There could be UIKit updates in the future reorganizing the inner view hierarchy of UIWebView. At that point this code may result in a very bad user experience.

By the way, we gonna give it a try.