I have two animations which are overlapping, which, because of the way I've set my method up, causes the second one not to fire. I have a check like so in the beginning of the method:
- (void)animateHidden:(BOOL)hidden duration:(CGFloat)seconds delay:(CGFloat)delay options:(UIViewAnimationOptions)options disableUserInteraction:(BOOL)disableUserInteraction {
if (self.hidden == hidden) {
return;
}
Then, further down, my animation block looks like so:
__weak UIView *weakSelf = self;
[UIView animateWithDuration:seconds delay:delay options:options animations:^{
weakSelf.alpha = hidden ? 0 : 1;
} completion:^(BOOL finished) {
// Return user interaction to previous state
if (disableUserInteraction) {
weakSelf.userInteractionEnabled = userInteractionEnabled;
}
weakSelf.hidden = hidden;
}];
Two animations are kicked off on the same view, one before a service call and one after. If the service call happens quick enough that the view is still animating, weakSelf.hidden = hidden;
will never be called, and the second animation will exit out since the hidden
value wasn't updated in time.
Is there anyway that I could force the completion block on the animation
block to be called? I need to update my hidden
property before making the check, but can't find a way to accomplish this.
Calling [self.layer removeAllAnimations]
doesn't seem to work unfortunately.
hidden
property / variable, check the.alpha
value? That would tell you if the animation is finished or not. – DonMagalpha
of 1, so checking for analpha
value that corresponds to ahidden
value doesn't work for all views. – Bill L