Animate AVPlayerLayer videoGravity propiedad

Estoy tratando de copiar el comportamiento de Apple en la reproducción de video que permite al usuario estirar la imagen de video para llenar los límites.

@interface FHVideoPlayerView : UIView
@end
@interface FHVideoPlayerView

+ (Class)layerClass
{
    return [AVPlayerLayer class];
}

- (void)setAspectMode:(FHVideoPlayerAspectMode)aspectMode animated:(BOOL)animated
{
    FHVideoPlayerAspectMode current = [self aspectMode];
    FHVideoPlayerAspectMode final   = aspectMode;

    NSString *fromValue;
    NSString *toValue;

    AVPlayerLayer *layer = (AVPlayerLayer *)[self layer];

    switch (current) {
        case FHVideoPlayerAspectFill:
            fromValue = AVLayerVideoGravityResizeAspectFill;
            break;
        case FHVideoPlayerAspectFit:
            fromValue = AVLayerVideoGravityResizeAspect;
            break;
       default:
           break;
    }

    switch (final) {
        case FHVideoPlayerAspectFill:
            toValue = AVLayerVideoGravityResizeAspectFill;
            break;
        case FHVideoPlayerAspectFit:
            toValue = AVLayerVideoGravityResizeAspect;
            break;
        default:
            break;
    }

    if (toValue != fromValue) {
        if (animated == YES) {
            // Manually added CABasicAnimation based on the understanding the implicit animations are disabled for CALayers that back a UIView
            CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"videoGravity"];
            [layer addAnimation:animation forKey:@"animateVideoGravity"];

            [CATransaction begin];
            [CATransaction setAnimationDuration:0.333];
        }

        [layer setVideoGravity:toValue];

        if (animated == YES) {
            [CATransaction commit];
        }
    }
}

Esto funciona bien cuando intento animar una propiedad numérica como la opacidad. Pero, notará en la referencia de clase, la propiedad videoGravity de AVPlayerLayer es un NSString. La referencia de clase señala que es animable.

Entonces mi pregunta es: ¿Cómo?

Creo que esto probablemente esté relacionado de alguna manera con la propiedad de contenido de CALayer y posiblemente con el contenido de Gravity.

Respuestas a la pregunta(4)

Su respuesta a la pregunta