Roei Nadam
Roei Nadam

Reputation: 1780

shadowOffset in UITableViewCell Causes slowness when scroll

I have UITable with cell:

enter image description here

when I scroll in the table I fell slow and fragmentation when table reload

when I remove the shadow code, the slow and fragmentation gone. but I need the shadow.

    self.layer.shadowOffset = CGSizeMake(-1,1);
    self.layer.shadowRadius = 2;
    self.layer.shadowColor = [[UIColor blackColor] CGColor];
    self.layer.shadowOpacity = 0.5;

Upvotes: 0

Views: 28

Answers (1)

psci
psci

Reputation: 933

Try to set shadowPath on layer property. Specifying an explicit path usually improves rendering performance.

 self.layer.shadowOffset = CGSizeMake(-1,1);
 self.layer.shadowRadius = 2;
 self.layer.shadowColor = [[UIColor blackColor] CGColor];
 self.layer.shadowOpacity = 0.5; 
 self.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:10].CGPath;

Using self.bounds as a path rect, make sure that view's frame is already set.

Upvotes: 1

Related Questions