Is there any way to disable rotation animation during changing device orientation portrait/landscape in only one UIView and its subviews.
Currently I'm using something like that from this post:
override func viewWillTransitionToSize(size: CGSize,
withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
CATransaction.begin()
CATransaction.setDisableActions(true)
coordinator.animateAlongsideTransition({ (ctx) -> Void in
}, completion: { (ctx) -> Void in
CATransaction.commit()
})
}
But this solution disable all the animations during changing the orientation in every UIView on the screen.
I was trying also to create special NotAnimatedView subclass of UIView with no luck at all:
class NotAnimatedView: UIView {
override func actionForLayer(layer: CALayer, forKey event: String) -> CAAction? {
if event == "bounds" || event == "position" {
return NSNull()
}
return super.actionForLayer(layer, forKey: event)
}
}
The "bounds" and "position" was the two events that was occuring during changing the orientation of the device so I override them and return NSNull() according to Apple Documentation
But It's not working. The NotAnimatedView is also animating. It seems that I don understand something or my understanding of CALayer is wrong. Can somebody put more light on this topic?