Reputation: 33
I have an AVPlayerViewController and want to display a UILabel over the player, but I cannot get the UILabel to appear. This used to work fine when I used an MPMoviePlayerViewController, but since switching to the AVPlayerViewController, it no longer works.
I am launching the AVPlayer like this:
AVPlayer *player = [AVPlayer playerWithURL:theURL];
AVPlayerViewController *theMovie = [[AVPlayerViewController alloc] init];
[self presentViewController:theMovie animated:YES completion:nil];
theMovie.player = player;
[player play];
The UILabel is defined as lblOverlayView and is setup like this:
lblOverlayView = [[UILabel alloc] init];
lblOverlayView.frame = CGRectMake(0, 100, self.view.frame.size.width, 60);
lblOverlayView.backgroundColor = [UIColor blackColor];
lblOverlayView.alpha = 0.5f;
NSString *combinedString1 = [@"Now Playing" stringByAppendingString:@" "];
NSString *combinedString2= [combinedString1 stringByAppendingString:@"Podcasts"];
lblOverlayView.text =combinedString2;
lblOverlayView.textColor = [UIColor whiteColor];
lblOverlayView.textAlignment = NSTextAlignmentCenter;
lblOverlayView.numberOfLines = 0;
lblOverlayView.font =[UIFont boldSystemFontOfSize:14];
lblOverlayView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin);
[theMovie.view addSubview:lblOverlayView];
[theMovie.view bringSubviewToFront:lblOverlayView];
How do I get the UILabel to appear?
Upvotes: 0
Views: 295
Reputation: 77423
Use the controller's .contentOverlayView
:
//[theMovie.view addSubview:lblOverlayView];
//[theMovie.view bringSubviewToFront:lblOverlayView];
[theMovie.contentOverlayView addSubview:lblOverlayView];
Upvotes: 2