NSString *urlPath;
NSURL *videoUrl;
urlPath = [[NSBundle mainBundle] pathForResource:@"fogLoop" ofType:@"mp4"];
videoUrl = [NSURL fileURLWithPath:urlPath];
avPlayer = [AVPlayer playerWithURL:videoUrl];
avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
avPlayerLayer.frame = videoView.layer.bounds;
avPlayerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[videoView.layer addSublayer: avPlayerLayer];
avPlayer.actionAtItemEnd = AVPlayerActionAtItemEndNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[avPlayer currentItem]];
[avPlayer play];
我在此 View 上有几个UILabel。我只希望视频确实是背景元素。使用此代码,它似乎可以播放所有UI元素。我如何使其进入后台?
最佳答案
您可以使用 View 图层的zPosition属性(它是CALayer对象)来更改 View 的z索引。
theView.layer.zPosition = 1;
并将标签带到前面
关于ios - AVPlayer-UILabel在视频中不可见,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14928243/