Modal status bar and navigation bar text colors from UIActivityViewControllers in iOS 7

后端 未结 6 2021
孤独总比滥情好
孤独总比滥情好 2021-01-01 16:50

When I\'m using a UIActivityViewController, after the user chooses an activity (such as Mail or Message), I can not change the text color for the status bar nor

6条回答
  •  太阳男子
    2021-01-01 17:40

    Rather than sub-classing from UIActivityViewController, we can change the tintColor of the navigation bar upon presenting it and revert it upon completion in the completionHandler. For example:

    UIColor *normalColor = [[UINavigationBar appearance] tintColor];
    UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil];
    [activityViewController setCompletionHandler:^(NSString *activityType, BOOL completed) {
          // back to normal color
         [[UINavigationBar appearance] setTintColor:normalColor];
    }];
    
    [self presentViewController:activityViewController animated:YES completion:^{
         // change color to suit your need
         [[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:25.0f/255.0f green:125.0f/255.0f blue:255.0f/255.0f alpha:1.0f]]; // ActionSheet options' Blue color
    }];
    

提交回复
热议问题