Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8533045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:51:51+00:00 2026-06-11T09:51:51+00:00

I styled a UIBarButtonItem using Appearance API like the following [[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal

  • 0

I styled a UIBarButtonItem using Appearance API like the following

[[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

This works great all over the app. The problem is, that this also changes the buttons in video views of YouTube videos that get loaded if you click a YouTube video in a uiwebview.

YouTube Examples

adding code like this:

[[UIBarButtonItem appearanceWhenContainedIn:[MPMoviePlayerViewController class], nil] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];

doesn’t change anything (because it seems the YouTube thing isn’t just a MPMoviePlayerViewController.

If I understand correctly, I am also not allowed to change the buttons of the YouTube view (and also I don’t want this).

Any ideas how I could stop setting custom bar button images on this YouTube video view?

Here is the sample project if you want to take a closer look: https://dl.dropbox.com/u/80699/BarItemsSample.zip

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:51:52+00:00Added an answer on June 11, 2026 at 9:51 am

    I believe I have come up with the most efficient solution currently available for this problem. Unfortunately the Youtube video player is of a private class called MPInlineVideoViewController. It is not possible to use the appearance proxy on this class, which would kind of be a hack anyway.

    Here is what I came up with. I coded it in a way that it could be used in more than one places and could also be used to solve other Appearance proxy issues, such as the back and next UIBarButtonItems when filling out a form in a UIWebView.

    AppDelegate.h

    extern NSString * const ToggleAppearanceStyles;
    

    AppDelegate.m

    NSString * const ToggleAppearanceStyles = @"ToggleAppearanceStyles";
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
        NSNotification *note = [NSNotification notificationWithName:ToggleAppearanceStyles object:NULL userInfo:@{@"flag" : @(YES)}];
        [self toggleAppearanceStyles:note];
    
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(toggleAppearanceStyles:) name:ToggleAppearanceStyles object:NULL];
    
        return YES;
    }
    -(void)toggleAppearanceStyles:(NSNotification *)note {
    
        UIImage *barButtonBgImage = nil;
        UIImage *barButtonBgImageActive = nil;
    
     if([note.userInfo[@"flag"] boolValue]) {
    
            barButtonBgImage = [[UIImage imageNamed:@"g_barbutton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 4, 15, 4)];
            barButtonBgImageActive = [[UIImage imageNamed:@"g_barbutton_active.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(15, 4, 15, 4)];
        }
    
        [[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
        [[UIBarButtonItem appearance] setBackgroundImage:barButtonBgImageActive forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];
    
    }
    

    MJWebViewController.m

    -(void)viewDidAppear:(BOOL)animated {
    
        [[NSNotificationCenter defaultCenter] postNotificationName:ToggleAppearanceStyles object:NULL userInfo:@{@"flag" : @(NO)}];
    
        [super viewDidAppear:animated];
    }
    -(void)viewWillDisappear:(BOOL)animated {
        [[NSNotificationCenter defaultCenter] postNotificationName:ToggleAppearanceStyles object:NULL userInfo:@{@"flag" : @(YES)}];
    
        [super viewWillDisappear:animated];
    }
    

    In the above code we toggle the appearance styles back to their default values so when the YouTube player is loaded, it uses the default styles. The current ViewController has already loaded so it will have the styled appearance.

    When the YouTube player dismisses, the current ViewController will not be reloaded, thus maintaining the styling. When the current ViewController disappears, the styled appearances are turned back on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have re-styled a textbox using a control template. The styling works well but
I am currently using the following code in the AppDelegate to make a UIBarButtonItem
I have created button for home like this: UIBarButtonItem * addButton=[[UIBarButtonItem alloc] initWithTitle:@Home style:UIBarButtonItemStyleBordered
I'm creating a styled QTreeView using double-dispatch to resolve specific delegate for data items,
I added a toolBar with this code: - (void)viewWillAppear:(BOOL)animated { UIBarButtonItem *yesterday = [[UIBarButtonItem
I am facing a problem in placing an image for an UIBarButtonItem. This is
I've added a button the my navigation bar like so: UIBarButtonItem *anotherButton = [[UIBarButtonItem
I am creating a toolbar in a Navigation Controller using the following code: [self.navigationController
I'm getting an analyser leak, however this is the same code i'm using elsewhere
I can't seem to add an image to this UIBarButtonItem without it crashing when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.