优化圆角性能

时间:2012-12-07 22:59:59

标签: iphone objective-c ios ipad

我的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时,它不会将细胞染成黄色。有什么方法可以改善这个? 这极大地伤害了我的滚动性能。我只是想设置圆角,里面有一些阴影。

1 个答案:

答案 0 :(得分: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];
相关问题