开发者

How to properly transform a UIView with a custom drawRect method

I've written a UIView subclass which adds a nice soft shadow underneath a png image. I'm overriding the drawRect method to draw the image and add the shadow.

Now, when I t开发者_StackOverflow社区ry to do a scale/rotate-affine transform on the UIView (by calling the .transform method), I'm not getting the result I'm looking for due to the initial "flattening" of the drawRect method.

I'd like to "redraw" the shadow so that it stays at the same offset when scaling. I tried to override the transform method and redraw the image but without success.

I was wondering if I'm currently looking in the correct direction.

  • Should I actually redraw the image and create complicated CG transforms and add the shadow every time again?
  • Is this a performant way of redrawing things?
  • The transform method seems to resize the whole container, mixing up the anti-aliassing of the whole image, resulting in jagged edges. Any thoughts on that?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜