Search code examples
ios5uinavigationbaruibarbuttonitemappearance

MPMoviePlayerViewController vs. Appearance-Framework (iOS 5)


i am using a MPMoviePlayerViewController inside my Project. I have defined the following appearance for UIButtons and UINavigationbar like so:

[[UIBarButtonItem   appearanceWhenContainedIn:[UINavigationBar class], nil]   
                    setBackgroundImage:[UIImage imageNamed:@"woodenBarButton"] 
                    forState:UIControlStateNormal 
                    barMetrics:UIBarMetricsDefault];

[[UINavigationBar appearance]   setBackgroundImage:[UIImage imageNamed:@"navigationbarBackground"] 
                                forBarMetrics:UIBarMetricsDefault];

So now MPMoviePlayerViewController is also using a navigation bar. The problem is now: The button uses the given appearance but the toolbar not => it looks crappy. So now i have the following questions:

  1. Can i convince the UINavigationBar in MPMoviePlayerViewController to use the appearance?
  2. OR can is remove appearance completely only for the MPMoviePlayerViewController.

I tried to access the button via playerViewController.navigationitem.leftbarbuttonitem and overwrite properties but that doesn't work.

Would be great if you can help me. Thanks.


Solution

  • have you tried also setting appearanceWhenContainedIn for MPMoviePlayerViewController? appearance and appearanceWhenContainedIn works both at the same time.

    [[UINavigationBar appearance]   setBackgroundImage:[UIImage imageNamed:@"navigationbarBackground"] 
                                forBarMetrics:UIBarMetricsDefault];
    [[UINavigationBar appearanceWhenContainedIn:[MPMoviePlayerViewController class], nil] setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];