Post

Replies

Boosts

Views

Activity

UIViewControllerTransitionCoordinator cannot coordinate view controller presentation animations along-side UIPropertyAnimator based animators
We use a UIPresentationController to coordinate animations for a presented view controller's veil (Apple called this "Chrome" in the WWDC 2014 session 228 - A Look Inside Presentation Controllers). The code below has been working on iOS 10 and now appears to be broken on iOS 11 as the UIView.alpha changes within the coordinator's animationAlongTransition block do not animate anymore, nor do they reverse if the transition is cancelled (didn't complete). From what I can tell, this breakage only occurs when using UIPropertyAnimator() since our other UIView.animate() based animators work just fine.Expected Results:The veil (chrome) in the sample code has a background color of UIColor(red: 1, green: 0, blue: 0, alpha: 0.4) for easy detection. The expectation is that as the view controller is presented, the veil animates from alpha 0 to alpha 1 behind the view controller inside of the transition container. Logically, as the view controller is dismissed, the veil animates from alpha 1 to alpha 0. The veil animation should also animate appropriately when the transition is interactive based on the transition context's percent complete.Observed Results:The observed results is that on iOS 10, everything works perfectly. On any version of the iOS 11 beta, the veil does not animate and instantly has it's alpha set. If a dismiss does not complete, the veil also does not revert back to it's original alpha.Apple support, for full code sample with animators please see attachement in bug report with ID: 34136178.@interface ModalPresentationController: UIPresentationController @end @implementation ModalPresentationController { UIView *veil; } - (instancetype)initWithPresentedViewController:(UIViewController *)presentedViewController presentingViewController:(UIViewController *)presentingViewController { if (self = [super initWithPresentedViewController:presentedViewController presentingViewController:presentingViewController]) { veil = [[UIView alloc] init]; veil.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4f]; } return self; } - (void)presentationTransitionWillBegin { veil.frame = self.containerView.bounds; veil.alpha = 0.0f; [self.containerView insertSubview:veil atIndex:0]; [self.presentedViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { veil.alpha = 1.0f; } completion:nil]; } - (void)dismissalTransitionWillBegin { [self.presentedViewController.transitionCoordinator animateAlongsideTransition:^(id<UIViewControllerTransitionCoordinatorContext> _Nonnull context) { veil.alpha = 0.f; } completion:nil]; } - (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; veil.size = size; } @end
4
0
2.3k
Aug ’17