AVPlayer - UILabel not showing over video

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]; 

I have several UILabels on this view. I just want the video as a background element really. With this code, it seems to reproduce all the user interface elements. How to make him go to the background?

+8
ios objective-c avplayer
source share
1 answer

You can use the zPosition property of the view layer (this is a CALayer object) to change the z-index of the view.

  theView.layer.zPosition = 1; 

And add tags forward

+7
source share

All Articles