There is no need for an image with rouned corners - see the answer by fknrdcls to this question:
UILabel layer cornerRadius negatively impacting performance
Basically, you simply need to give your label a transparent background, and add the backgroundcolor to the layer instead. Then, you can disable maskToBounds
, which greatly improves performance. So your code becomes:
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(cell.bounds.origin.x+10 ,5, 30, 30)];
label1.backgroundColor = [UIColor clearColor];
label1.layer.backgroundColor=[UIColor whiteColor].CGColor;
label1.layer.cornerRadius = 10.0f;
label1.layer.masksToBounds = NO;
label1.layer.shouldRasterize = YES;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…