I am using drawRect:
to draw shapes. I have to invoke this method and redraw the shapes when orientation changes, so i thought if there is a way to invoke drawRect:
automatically when layoutSubviews()
been called.
Thank you.
You can set the view's contentMode
to .redraw
.
This will invoke setNeedsDisplay
(and therefore drawRect
) whenever the view's bounds change, and will therefore also be invoked upon rotation (provided you've setup your autoresizingMask
so that the view's bounds change on rotation).