问题描述
我正在尝试使用 AVPlayerLayer
之上的 UIImage
显示视频。视频应该调整自身大小,以便在图像视图中显示完整视频,即使它必须拉伸自己才能做到这一点。
不幸的是我没有得到这些结果,我的视频最终在模拟器上看起来像这样。
Image of the results
我尝试将 AVPlayerLayer.frame 手册设置为图像视图大小,以演示我的目标是在所有不同的 iPhone 尺寸上看起来像什么。 Image of the goal results
这是我的代码:
let playerLayer = AVPlayerLayer(player: queuePlayer)
playerLayer.frame = feedBackground.bounds
playerLayer.videoGravity = .resizeAspectFill
feedBackground.layer.masksToBounds = true
feedBackground.layer.addSublayer(playerLayer)
(feedBackground 是一个 UIImage)
不知道它是否重要,但 feedBackground 的 contentMode 是缩放以填充
我对应用程序开发很陌生,所以感谢您花时间阅读我的问题,并感谢您提供的任何解决方案:)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)