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 时,它​​不会将单元格着色为黄色。有什么方法可以改善这种情况?这极大地损害了我的滚动性能。我只是想设置带有一些阴影的圆角。

4

1 回答 1

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];
于 2012-12-08T04:49:32.743 回答