How to properly convert a UIView using the special drawRect method

I wrote a subclass of UIView that adds a nice soft shadow under the png image. I override the drawRect method to draw an image and add a shadow.

Now, when I try to do arithmetic transformation of scale / rotation on a UIView (by calling the .transform method), I do not get the result that I am looking for due to the initial "smoothing" of the drawRect method.

I would like to “redraw” the shadow so that when scaling it remains at the same offset. I tried to override the conversion method and redraw the image, but to no avail.

I was wondering if I was looking in the right direction.

  • Should I redraw the image and create complex CG transforms and add a shadow every time again?
  • Is this the usual way to redraw things?
  • The conversion method seems to resize the entire container by mixing anti-aliasing of the entire image, resulting in jagged edges. Any thoughts on this?
+3
source share

Source: https://habr.com/ru/post/1754299/


All Articles