6
votes

Whenever the user wants to select a new share method or action that isn't listed by default, by tapping the "More" button on the UIActivityViewController generated share sheet, a new view is displayed, something like this:

Followup view

As you can see, the navigation bar itens are white, while it's background is a light grey. How can I change these colors to reflect my app UI?

4

4 Answers

5
votes

I did this and it works for me:

Sublclass UIActivityViewController and override -(void)presentViewController:animated:completion:

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
[viewControllerToPresent.view setTintColor:[[UINavigationBar appearance] tintColor]];
for (UIView *view in viewControllerToPresent.view.subviews) {
    if ([view isKindOfClass:[UINavigationBar class]]) {
        UINavigationBar *navigationBar = (UINavigationBar*)view;
        UIImage *navigationBarImage = [[UINavigationBar appearance] backgroundImageForBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
        [navigationBar setBackgroundImage:navigationBarImage forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
        [navigationBar setTitleTextAttributes:[[UINavigationBar appearance] titleTextAttributes]];
    }
}

[super presentViewController:viewControllerToPresent animated:flag completion:^{
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    if (completion) {
        completion();
    }
}];
}
1
votes

set this property on the modal before opening, something like:

modal.navigationController.navigationBar.barTintColor = ...

Could you please provide some code for us to see what you are trying now?

0
votes

Set the tintColor and barTintColor on the navigation bar:

    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationController.navigationBar.barTintColor = [UIColor blueColor];

tintColor is for the navigation items and bar button items barTintColor if for the navigation bar background.

0
votes

You are likely using UIAppearance selectors to modify all navigation bars on your app by calling it on the class. Instead, call the appearance methods on individual objects, which will spare system navigation bars from being colored like this.