Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIActivityViewController has wrong button title colors

I'm having a weird issue presenting a UIActivityViewController.

When I present a UIActivityViewController from my application's root view, the button titles are the correct color.

Now, but if I navigate back to the root view controller from a detail view controller and present the UIActivityViewController listed above, the presented controller is inheriting the presenting controller's button title colors for some reason. I've tried forcing the bar style to default, but that doesn't work either. Setting the UIActivityViewController's button appearance doesn't work like it does a MFMailComposeViewController.

Any help offered is greatly appreciated! Screenshots:

enter image description here enter image description here

Code I'm using to set my detailviewcontroller's button color:

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.navigationController.navigationBar.topItem.title = @"Back";

    UIButton *Button2 = [UIButton buttonWithType:UIButtonTypeCustom];
    [Button2 addTarget:self action:@selector(heh) forControlEvents:UIControlEventTouchUpInside];
    [Button2 setImage:[UIImage imageNamed:@"button.png"] forState:UIControlStateNormal];
    [Button2 setImage:[UIImage imageNamed:@"buttonPressed.png"] forState:UIControlStateHighlighted];
    Button2.frame = CGRectMake(0.0, 0.0, 44, 44);

    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:Button2];
}
like image 718
klcjr89 Avatar asked Dec 07 '25 06:12

klcjr89


1 Answers

I solved the problem, I had to manually change my detail view controller's bar button item title colors after dismissing the UIActivityViewController.

[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], [UIViewController class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor blackColor], UITextAttributeTextColor, [UIColor clearColor], UITextAttributeTextShadowColor, CGSizeMake(0, 0), UITextAttributeTextShadowOffset, [UIFont fontWithName:@"HelveticaNeue-Light" size:16], UITextAttributeFont, nil]
                                                                                        forState:UIControlStateNormal];
like image 116
klcjr89 Avatar answered Dec 08 '25 19:12

klcjr89



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!