I have a class which is a subclass of UIView. I am able to draw stuff inside the view either by implementing the drawRect method, or by implementin
On iOS, the overlap between a view and its layer is very large. By default, the view is the delegate of its layer and implements the layer's drawLayer:inContext: method. As I understand it, drawRect: and drawLayer:inContext: are more or less equivalent in this case. Possibly, the default implementation of drawLayer:inContext: calls drawRect:, or drawRect: is only called if drawLayer:inContext: is not implemented by your subclass.
How to decide which approach to use? Is there a use case for each one?
It doesn't really matter. To follow the convention, I would normally use drawRect: and reserve the use of drawLayer:inContext: when I actually have to draw custom sublayers that are not part of a view.