这是我的代码:
self.playerView?.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2));
self.playerView?.setVideoGravity(AVLayerVideoGravityResizeAspectFill)
self.playerView?.setMovieToPlayer(mp)
从纵向转变为景观的第一条线...... mp是AVPlayer ..
故事板图片和黑色是playerView
ViewController MainView
,约束是
trailing = Player View.trailing
Player View.bottom = Bottom Layout Guide.top
Player View.top = top
Player View.leading = leading
输出为:视图不占用全屏但留下一些左右空间
有人帮忙吗? Atleast提供一些教程......
答案 0 :(得分:1)
这是因为您在初始化AVLayerVideoGravityResizeAspectFill
时指定了playerView
。根据{{3}}:
AVLayerVideoGravityResizeAspectFill
指定播放器应保留视频的宽高比并填充图层的边界。