Allow User Interaction For Animations With Forwards Fill Mode
obahareth opened this issue · comments
So I did a simple opacity animation on a table view, and I disabled removedOnCompletion, and set the fill mode to forwards so the animation doesn't reset when it ends. However, that disallows user interaction. The animation needs to be configured to have the UIViewAnimationOptionAllowUserInteraction flag, does RBBAnimation allow this flag to be set?
Here's my sample code:
RBBTweenAnimation *opacityAnimation = [RBBTweenAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.fromValue = @(0.0f);
opacityAnimation.toValue = @(1.0f);
opacityAnimation.easing = RBBEasingFunctionLinear;
opacityAnimation.duration = 0.2f;
opacityAnimation.fillMode = @"forwards";
opacityAnimation.cumulative = false;
opacityAnimation.additive = false;
opacityAnimation.removedOnCompletion = false;
[self.tableView.layer addAnimation:opacityAnimation forKey:@"Animation"];
hitTest:withEvent:
returns NO
if the views alpha is less than 0.01 – can you make sure the behavior you are seeing is not because of that? I.e. does this work?
RBBTweenAnimation *opacityAnimation = [RBBTweenAnimation animationWithKeyPath:@"opacity"];
opacityAnimation.fromValue = @(0.0f);
opacityAnimation.toValue = @(1.0f);
opacityAnimation.easing = RBBEasingFunctionLinear;
opacityAnimation.duration = 0.2f;
opacityAnimation.fillMode = kCAFillModeForwards;
opacityAnimation.cumulative = NO
opacityAnimation.additive = NO;
opacityAnimation.removedOnCompletion = YES;
[self.tableView.layer addAnimation:opacityAnimation forKey:@"Animation"];
self.tableView.layer.opacity = 1.0f;
I'll give it a shot later today and see what happens.
Any luck?
Yes, that does work, and the animation no longer resets even though removedOnCompletion is set to true. Without that last line, the animation resets to opacity 0 when it ends. Is that how it works then? You always need to set the end value on the layer as you're performing the animation?
Also, I sincerely apologize for taking so long to test this out, had a hectic time in my life.
Is that how it works then? You always need to set the end value on the layer as you're performing the animation?
Yeah, pretty much. In this case, the layer that you see is the presentationLayer
but the layer used for hit-testing is the actual one. I guess you also don't need to set the fill mode anymore.
Also, I sincerely apologize for taking so long to test this out, had a hectic time in my life.
No worries, happy that I could help