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:
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?
From Settings, tap Display, and then tap Navigation bar. Make sure Buttons is selected, and then you can choose your desired button setup at the bottom of the screen. Note: This option will also affect the location you swipe when using Swipe gestures.
Go to the ViewController. swift file and add the ViewDidAppear method. a nav helper variable which saves typing. the Navigation Bar Style is set to black and the tint color is set to yellow, this will change the bar button items to yellow.
Change the Bar StyleA user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.
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();
}
}];
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With