Reputation: 1157
if I use layer.shadow like this:
self.layer.shadowOffset = CGSizeMake(0, 1.5);
self.layer.shadowColor = [UIColor grayColor].CGColor;
self.layer.shadowOpacity = 1;
and put some(not more than 10) of these views(without images) into a UIScrollView
,
it makes the scrollView
very slow when is scrolling.
if I remove any codes about shadow, scrolling become quite smooth again.
FYI, the un-smooth case happen when running the app on iOS device, but smooth on iOS simulator.
Does any one know how to keep both shadow and smooth scrolling?
Upvotes: 1
Views: 3638
Reputation: 256
It will help if you set a shadow path and set the should rasterize flag on the layer.
Something like this:
UIBezierPath *path = [UIBezierPath bezierPathWithRect:self.bounds];
self.layer.shadowPath = [path CGPath];
self.layer.shouldRasterize = YES;
Upvotes: 8