简体   繁体   English

优化圆角性能

[英]optimizing rounded corners performance

I have the following code in my UITableViewCell: 我的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];

when I run instrument and set color offscreen - rendered yellow, this causes the cell to be yellow. 当我运行仪器并在屏幕外设置颜色-呈现黄色时,这会使单元格变为黄色。 When I remove the shouldRasterize it doesn't shade the cells to yellow. 当我删除shouldRasterize时,它不会将单元格着色为黄色。 What are ways to improve this? 有什么方法可以改善这一点? This is greatly hurting my scrolling performance. 这极大地损害了我的滚动性能。 I am just trying to set rounded corners with some shadows in it. 我只是想在其中设置一些阴影的圆角。

I'm doing rounded corners like this: 我在做这样的圆角:

    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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM