For future reference; in the end, I solved it by using a custom UITableView subclass which added a empty but shadowed layer in its layoutSubviews method:
ShadowTableView.h:
@interface ShadowTableView : UITableView {
CALayer *shadowLayer;
}
@end
ShadowTableView.m:
#import "ShadowTableView.h"
#import <QuartzCore/QuartzCore.h>
@implementation ShadowTableView
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style {
self = [super initWithFrame:frame style:style];
if (self) {
shadowLayer = [[CALayer alloc] init];
shadowLayer.backgroundColor = [kCellBgColor CGColor];
shadowLayer.cornerRadius = 10.0;
shadowLayer.shadowOpacity = 1.6;
shadowLayer.shadowOffset = CGSizeMake(0, 3);
shadowLayer.shadowColor = [[UIColor blackColor] CGColor];
shadowLayer.shadowRadius = 8.0;
}
return self;
}
- (void)dealloc {
[shadowLayer release];
[super dealloc];
}
- (void)layoutSubviews {
[super layoutSubviews];
if (!shadowLayer.superlayer) {
[self.layer insertSublayer:shadowLayer atIndex:0];
}
shadowLayer.frame = CGRectMake(10.0, 10.0, 300.0,
self.rowHeight * [self.dataSource tableView:self numberOfRowsInSection:0] + 1);
}
@end
CGContextSetShadowWithColorin a cell background view but the shadows get clipped on the tablecell's bounds. So, also no success so far. - alexleutgoeb