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

前端 未结 2 1718
被撕碎了的回忆
被撕碎了的回忆 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条回答
  •  旧时难觅i
    2020-12-23 18:41

    Thought I should make an answer because I didn't want this gem to get buried in the comments.

    In addition to cobbal's answer above, which helped a lot, occulus also mentioned the following optimization for non-rectangular shadows, such as text shadows.

    self.contentView.layer.shouldRasterize = YES;
    // Fix visual degradation when rasterizing on high-density screens:
    self.contentView.layer.rasterizationScale = [[UIScreen mainScreen] scale];
    

提交回复
热议问题