Question

I have white background and white label on it, so I need to give a shadow all side of characters I use this code and it works! but it cause to slowly scroll do you have any idea how can solve this problem?

cell.L_name.layer.shadowOpacity = 1.0;
cell.L_name.layer.shadowRadius = 1.0;
cell.L_name.layer.shadowColor = [UIColor blackColor].CGColor;
cell.L_name.layer.shadowOffset = CGSizeMake(1.0, 1.0);
Était-ce utile?

La solution

try setting

cell.L_name.layer.shouldRasterize = YES;

this will render your label as a bitmap and might improve scrolling smoothness

additionally you could set

cell.opaque = YES;

which will optimize drawing performance as well.

Autres conseils

Setting a shadowPath for the layer would probably increase the performance greatly.

cell.L_name.layer.shadowPath = [UIBezierPath pathWithRect:L_name.bounds].CGPath;

Besides, you can cache the generated shadow as a bitmap, which also increases the performance considerably. Do not forget to set rasterizationScale for retina displays.

cell.L_name.layer.shouldRasterize = YES;
cell.L_name.layer.rasterizationScale = [UIScreen mainScreen].scale;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top