diff --git a/MaterialControls/MaterialControls/MDRippleLayer.m b/MaterialControls/MaterialControls/MDRippleLayer.m index 5d6a50b..c073540 100644 --- a/MaterialControls/MaterialControls/MDRippleLayer.m +++ b/MaterialControls/MaterialControls/MDRippleLayer.m @@ -133,9 +133,9 @@ - (void)removeFromSuperlayer { } - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { - if (anim == [self animationForKey:@"opacityAnim"]) { - self.opacity = 0; - } else if (flag) { + if([[anim valueForKey:@"opacityAnim"] isEqual:@"opacity"]) { + self.opacity = 0; + } else if (flag) { if (_userIsHolding) { _effectIsRunning = false; if ([self.layerDelegate respondsToSelector:@selector(mdLayer:didFinishEffect:)]) { @@ -144,6 +144,8 @@ - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag { } else { [self clearEffects]; } + } else { + [self clearEffects]; } } @@ -324,7 +326,7 @@ - (void)clearEffects { opacityAnim.removedOnCompletion = false; opacityAnim.fillMode = kCAFillModeForwards; opacityAnim.delegate = self; - + [opacityAnim setValue:@"opacity" forKey:@"opacityAnim"]; [self addAnimation:opacityAnim forKey:@"opacityAnim"]; } diff --git a/MaterialControls/MaterialControls/MDTabBarViewController.m b/MaterialControls/MaterialControls/MDTabBarViewController.m index 840bf32..d3b3d25 100644 --- a/MaterialControls/MaterialControls/MDTabBarViewController.m +++ b/MaterialControls/MaterialControls/MDTabBarViewController.m @@ -222,22 +222,24 @@ - (void)moveToPage:(NSUInteger)selectedIndex { __unsafe_unretained typeof(self) weakSelf = self; disableDragging = YES; pageController.view.userInteractionEnabled = NO; - [pageController - setViewControllers:@[ viewController ] - direction:animateDirection - animated:YES - completion:^(BOOL finished) { - weakSelf->disableDragging = NO; - weakSelf->pageController.view.userInteractionEnabled = YES; - weakSelf->lastIndex = selectedIndex; - - if ([weakSelf->_delegate - respondsToSelector:@selector(tabBarViewController: - didMoveToIndex:)]) { - [weakSelf->_delegate tabBarViewController:weakSelf - didMoveToIndex:selectedIndex]; - } - }]; + dispatch_async(dispatch_get_main_queue(), ^{ + [pageController + setViewControllers:@[ viewController ] + direction:animateDirection + animated:NO + completion:^(BOOL finished) { + weakSelf->disableDragging = NO; + weakSelf->pageController.view.userInteractionEnabled = YES; + weakSelf->lastIndex = selectedIndex; + + if ([weakSelf->_delegate + respondsToSelector:@selector(tabBarViewController: + didMoveToIndex:)]) { + [weakSelf->_delegate tabBarViewController:weakSelf + didMoveToIndex:selectedIndex]; + } + }]; + }); } #pragma mark - PageViewController Delegate