2012-12-07 103 views
2

我在我的UITableViewCell下面的代码:优化圆角性能

[self.layer setBorderColor:[UIColor blackColor].CGColor]; 
    [self.layer setShadowRadius:10.0]; 
    [self.layer setCornerRadius:5.0]; 
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(5.0, 5.0)]; 
    [self.layer setShadowPath:path.CGPath]; 
    [self.layer setShouldRasterize:YES]; 
    [self.layer setRasterizationScale:[UIScreen mainScreen].scale]; 

当我运行仪器,并设置颜色屏幕外 - 呈现黄色,这导致细胞是黄色的。当我移除shouldRasterize时,它不会使细胞变黄。有什么方法可以改善这一点? 这大大伤害了我的滚动性能。我只是想设置一些带有阴影的圆角。

回答

0

我做的圆角这样的:

self.layer.shadowColor = [UIColor grayColor].CGColor; 
    self.layer.shadowOffset = CGSizeMake(0.05, 0.05); 
    self.layer.shadowOpacity = 10; 
    self.layer.shadowRadius = 1.5; 
    self.layer.masksToBounds = NO; 
    self.layer.shouldRasterize = YES; 
    [self.layer setBorderColor: [[UIColor whiteColor] CGColor]]; 
    [self.layer setBorderWidth: 5.0]; 
+0

这并没有帮助。我尝试过,当我使用屏幕外的颜色进行配置文件时,仍然给我一个黄色单元格 – adit