简体   繁体   中英

Objective C : How to change the background color for the toolBar of MPMoviePlayerController

In my app i have to play the video on MPMoviePlayerController. For this i wrote the code as bellow.

- (void)playVideo
{
    //[imagePikerView removeFromSuperview];
    moviePlayerController = [[MPMoviePlayerController alloc] init];
    NSURL *url = [NSURL fileURLWithPath: self.VideoPath];
    [moviePlayerController setContentURL: url];

    int x = 50;
    int y = 50;
    int width =  CGRectGetHeight(self.view.frame)- 2*x;
      int height =  CGRectGetWidth(self.view.frame)- 50; //height = width in landscape mode
    [moviePlayerController.view setFrame: CGRectMake(x, y, width, height)];


    moviePlayerController.backgroundView.backgroundColor = [UIColor clearColor];

    //NSLog(@"[moviePlayerController.view subviews] === %@",);

    for (UIView *viw in [moviePlayerController.view subviews]) {
        NSLog(@"[moviePlayerController.view subviews] === %@",[viw subviews]); ;
    }


    [self.view addSubview:moviePlayerController.view];
    [moviePlayerController play];


}

I want to change that black transparent tool bar color to redColor, (shown with the arrow)

在此处输入图片说明

if you want to change the whole background colour you could use

moviePlayer.backgroundColor = [UIColor redColor];

otherwise, first reset it to null

this.NavigationController.NavigationBar.TintColor = null;
this.NavigationController.NavigationBar.BarTintColor = null;

then apply the color eg

tabBarController.Appearance.barTintColor = UIColor.Red;
tabBarController.Appearance.TintColor = UIColor.Red;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM