UITableView阴影

CGColorRef darkColor = [[UIColor blackColor] colorWithAlphaComponent:.5f].CGColor;
CGColorRef lightColor = [UIColor clearColor].CGColor;

//Footer shadow
UIView *footerShadow = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];

CAGradientLayer *bottomShadow = [[[CAGradientLayer alloc] init] autorelease];
bottomShadow.frame = CGRectMake(0,0, self.view.frame.size.width, 10);
bottomShadow.colors = [NSArray arrayWithObjects:(id)darkColor, (id)lightColor, nil];
footerShadow.alpha = 0.6;

[footerShadow.layer addSublayer:bottomShadow];
tb.tableFooterView = footerShadow;

//Header shadow
UIView *headerShadow = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 10)];

CAGradientLayer *topShadow = [[[CAGradientLayer alloc] init] autorelease];
topShadow.frame = CGRectMake(0, 0, self.view.frame.size.width, 10);
topShadow.colors = [NSArray arrayWithObjects:(id)lightColor, (id)darkColor, nil];
headerShadow.alpha = 0.3;

[headerShadow.layer addSublayer:topShadow];
tb.tableHeaderView = headerShadow;

tb.contentInset = UIEdgeInsetsMake(-10, 0, 0, 0);

posted @ 2012-10-19 11:44  LeeTVin  阅读(395)  评论(0编辑  收藏  举报