Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPVolumeView animation on iOS 8

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 problem on iOS 7.

like image 859
Alexander Woodblock Avatar asked Sep 16 '14 12:09

Alexander Woodblock


1 Answers

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:).

like image 64
Patrik Avatar answered Oct 20 '22 15:10

Patrik