MPVolumeView animation on iOS 8

前端 未结 1 1112
独厮守ぢ
独厮守ぢ 2021-02-14 20:49

In iOS 8 there is a problem or a feature. When MPVolumeView is shown, it\'s being animated, like expanding from 0 to it\'s width. How can I fix that behavior? There was no such

相关标签:
1条回答
  • 2021-02-14 21:34

    One possible way to remove this behavior is to subclass MPVolumeView and perform some additional work after [super layoutSubviews].

    - (void)layoutSubviews
    {
        [super layoutSubviews];
    
        [self cg_recursiveRemoveAnimationsOnView:self];
    }
    
    - (void)cg_recursiveRemoveAnimationsOnView:(UIView *)view
    {
        [view.layer removeAllAnimations];
        for (UIView *subview in view.subviews) {
            [self cg_recursiveRemoveAnimationsOnView:subview];
        }
    }
    

    This removes all inserted animations. So be sure that is what you want, since this is quite the overkill. One could also just remove the position and bounds animations (see removeAnimationForKey:).

    0 讨论(0)
提交回复
热议问题