在 AVPlayerViewController 上显示一个 UILabel

Display a UILabel over AVPlayerViewController

我有一个 AVPlayerViewController 并想在播放器上显示一个 UILabel,但我无法让 UILabel 出现。这曾经在我使用 MPMoviePlayerViewController 时工作正常,但自从切换到 AVPlayerViewController 后,它不再工作了。

我是这样启动 AVPlayer 的:

        AVPlayer *player = [AVPlayer playerWithURL:theURL];
        AVPlayerViewController *theMovie = [[AVPlayerViewController alloc] init];
        [self presentViewController:theMovie animated:YES completion:nil];
        theMovie.player = player;
        [player play];

UILabel 定义为 lblOverlayView,设置如下:

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

如何让 UILabel 出现?

使用控制器的.contentOverlayView:

//[theMovie.view addSubview:lblOverlayView];
//[theMovie.view bringSubviewToFront:lblOverlayView];

[theMovie.contentOverlayView addSubview:lblOverlayView];