I am making a drawing app and I would like the user to be able to rotate their device and draw on the canvas in any orientation. The toolbar of brushes/colors/etc needs to change orientation to always be on the top of the screen HOWEVER the drawing canvas needs to NOT change orientation (so as to preserve the drawing's orientation; imagine rotating a piece of paper with a drawing on it - the drawing would sometimes be sideways or upside down but your pencils would be still right in front of you).
I have tried several attempts and have concluded that I DO want to support iOS's default orientation changes because things like UIAlert popups need to be oriented correctly. Implementing override var supportedInterfaceOrientations: UIInterfaceOrientationMask
on the view controller is not the best option.
I have gotten closer by subscribing to device orientation changed notifications
and rotating the drawing canvas in the opposite direction to compensate for the default UI orientation rotation. In this case I am applying a CGAffineTransform rotation of 90, -90, 0, or 180 degrees to the canvas container view but its subviews are not rotating correctly with it.
Any ideas that I may be missing to get the behavior I want?
This is what I want. Notice how the toolbar is always being oriented to the top after rotation but the drawing stays glued to the device.
Before orientation change:
After orientation change: