I Have bad performance on using shadow effect

后端 未结 4 1724
时光取名叫无心
时光取名叫无心 2021-02-08 12:33

I put some image views on scroll view. And when I drag this scroll view, I didn\'t have any problems.

But after I applied shadow effect to these image views, dragging th

4条回答
  •  逝去的感伤
    2021-02-08 13:12

    Whenever you work with shadows its better to use a bezier path as the background. This will help you set the shadowPath, which will drastically improve performance. Rasterize will improve performance, but setShadowPath will improve 5x more than just setting rasterize.

    path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(0, 0, 100, 100) cornerRadius:10];
    [self.layer setShadowColor:[UIColor blackColor].CGColor];
    [self.layer setShadowOpacity:1.0f];
    [self.layer setShadowRadius:10.0f];
    [self.layer setShadowPath:[path CGPath]];
    

提交回复
热议问题