AVPlayerLayer动画帧更改 [英] AVPlayerLayer animates frame changes

查看:690
本文介绍了AVPlayerLayer动画帧更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我更改AVPlayerLayer的帧时,视频不会立即调整大小,而是动画为新大小。



例如:我更改了帧( 0,0,100,100)到(0,0,400,400),视图的帧立即更改,但视频的大小设置为新大小。



<有没有人遇到过这个问题?如果是,有人知道一种方法来禁用默认动画吗?



谢谢!

解决方案

您可以尝试禁用隐式操作并使用零长度动画:

  CALayer * videolayer =< #AVPlayerLayer #> 
[CATransaction begin];
[CATransaction setAnimationDuration:0];
[CATransaction setDisableActions:YES];
CGRect rect = videolayer.bounds;
rect.size.width / = 3;
rect.size.height / = 3;
videolayer.bounds = rect;
[CATransaction commit];


Whenever I change the frame of my AVPlayerLayer, the video is not resized immediately, but animated to the new size.

For example: I change the frame from (0, 0, 100, 100) to (0, 0, 400, 400), the view's frame is changed immediately, but the video's size is animated to the new size.

Has anyone encountered this issue? And if yes does someone know a way to disable the default animation?

Thanks!

解决方案

You can try disabling implicit actions and using zero length animations:

CALayer *videolayer = <# AVPlayerLayer #>
[CATransaction begin];
[CATransaction setAnimationDuration:0];
[CATransaction setDisableActions:YES];
CGRect rect = videolayer.bounds;
rect.size.width /= 3;
rect.size.height /= 3;
videolayer.bounds = rect; 
[CATransaction commit];

这篇关于AVPlayerLayer动画帧更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆