Appearance of UIBarButtonItem I need an exception

In mine, application:didFinishLauchginWithOptions:I set default values ​​for my controls.

UIImage *transparentImage = [UIImage imageNamed:@"transparent.png"];

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

this works great for me as it gives the regular UIBarButtonItems a transparent flat look. However, there is an I button, which is presented with UIDocumentInteractionControllerwhen you click the “quick look”, which does not have the correct appearance.

enter image description here

I believe that this is the only barbuttonitem that I have, it's just an image. Is there a way I can change this button to give it some contrast, so it doesn't look so ugly? even the original background looks fine against my naviagationbar.

+5
source share
1

documentInteractionControllerWillBeginPreview, documentInteractionControllerDidEndPreview

willBegin navigationItem . , didEnd , .

- (void)documentInteractionControllerWillBeginPreview:(UIDocumentInteractionController *)controller
{
    [[UIBarButtonItem appearance] setBackgroundImage:nil forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:nil forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:nil forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

    self.rightButton = self.navigationItem.rightBarButtonItem;
    self.navigationItem.rightBarButtonItem = nil;
}

- (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
{
    UIImage *transparentImage = [UIImage imageNamed:@"transparent.png"];
    [[UIBarButtonItem appearance] setBackgroundImage:transparentImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:transparentImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
    [[UIBarButtonItem appearance] setBackgroundImage:transparentImage forState:UIControlStateSelected barMetrics:UIBarMetricsDefault];

    self.navigationItem.rightBarButtonItem = self.rightButton;
}

, , . - , rightBarButtonItem, .

0

All Articles