Drawing shadow with Quartz is slow on iPhone & iPad. Another way?

前端 未结 2 1723
被撕碎了的回忆
被撕碎了的回忆 2020-12-23 17:45

I was pretty excited when I found out just how easy it is to add shadows to my UIViews on the iPhone/iPad.

Just add the framework in Xcode, add the import to the top

2条回答
  •  甜味超标
    2020-12-23 18:27

    You should set the shadowPath property. It is how CoreGraphics is able to optimize shadows.

    For example, if your view is an opaque rectangle:

    self.contentView.layer.shadowPath = [UIBezierPath bezierPathWithRect:self.contentView.bounds].CGPath;
    

提交回复
热议问题