Have a white fullscreen view with a couple subviews, say a couple of labels.
{Aside - I always make such views rotate "logically", exactly as explained by Natasha HERE. I mention this in case it is relevant to the behavior, but the behavior seems to happen regardless.}
When the iPhone is rotated...
Let's make everything disappear,
class CalmRotation: UIViewController {
override func willTransition(to newCollection: UITraitCollection,
with coordinator: UIViewControllerTransitionCoordinator) {
for v in view.subviews { v.alpha = 0 }
after the rotation, bring them back...
let s = coordinator.transitionDuration * 0.5
coordinator.animate(alongsideTransition: { _ in
},completion: { [weak self] _ in
for v in self?.view.subviews ?? [] {
UIView.animate(withDuration:s, animations:{v.alpha = 1})}
})
super.willTransition(to: newCollection, with: coordinator)
}
Try this in today's new Xcode, in any simulator. Tap command-arrow to rotate that sucker.
Notice a disturbing flicker.
At alpha=0, the labels don't really want to go away.
(If you simply leave off the come-back animation, it makes no difference, you'll still see the flicker in the simulator. Obviously just restart the stub app each time to test, as the views will be gone.)
So there's a flicker.
However, it does seem to work perfectly on a device.
But that could be a "fake positive" - since rotations are triggered so slowly on a device.
-
In fact, is there actually a call "will .. WillTransition" so that we can know a transition is about to happen? That would, in general, seem a better way to do something you want done before a transition happens, and would presumably solve such flicker events.
-
Have I f'd up something else in the above code which someone can spot a flicker in?
-
If this is a flaw in the simulators, you'd think it would be pretty well known, so that seems dubious.
from Flicker in transition anime (simulator?)
No comments:
Post a Comment