DrawRect
method on UIImageView
is slightly different than UIView
The view still has a CALayer, but the layer doesn’t allocate a backing store. Instead it uses a CGImageRef as its contents and the render server will draw that image’s bits into the frame buffer.
In this case, there’s no drawing going on. We’re simply passing bitmap data in form of an image to the UIImageView.
refer to this article Getting Pixels onto the Screen,And as my experience,that's why you can't get your imageView clip method worked.
Here is my solution:
- Instead of creating a subclass of
AsyncImageView
, create a subClass ofUIView
. - Add
AsyncImageView
, which means your subClass become a wrapper view ofAsyncImageView
. - Implement the clip method in drawRect, and let asyncImageView handle it's content changes.