Search code examples
ioscalayeruiinterfaceorientation

How can I access interfaceOrientation in a custom CALayer?


I am have a custom CALayer which should look different with respect to different interface orientation. Is there a way that I can access the interfaceOrientation of the View Controller where I am using this CALayer ?

Or I will have to set a property in the custom Layer indicating the current orientation every time it changes ?


Solution

  • You could set a property on the custom layer.

    Or you could give the custom layer a property that references the view controller so it can just ask the view controller for the interface orientation when the layer needs to know.

    Or you could have your view controller post an NSNotification when it rotates, and have the layer observe the notification.