2012-02-12 164 views

回答

13

你可以使用一個CAGradientLayer。在您的cellForRowAtIndexPath中,創建單元格時,創建一個漸變圖層並將其添加到您的單元格。請注意,您必須導入QuartzCore框架。像這樣,

 //top shadow 
     UIView *topShadowView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.tableView.bounds.size.width, 10)]; 
     CAGradientLayer *topShadow = [CAGradientLayer layer]; 
     topShadow.frame = CGRectMake(0, 0, self.tableView.bounds.size.width, 10); 
     topShadow.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithWhite:0.0 alpha:0.25f] CGColor], (id)[[UIColor clearColor] CGColor], nil]; 
     [topShadowView.layer insertSublayer:topShadow atIndex:0]; 

     [cell.contentView addSubview:topShadowView]; 
+0

的感謝!精美的作品! – edc1591 2012-02-12 04:24:35