react-native-navigation的迁移库

RNNStatusBarOptions.m 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "RNNStatusBarOptions.h"
  2. #define kStatusBarAnimationDuration 0.35
  3. const NSInteger BLUR_STATUS_TAG = 78264801;
  4. const NSInteger BLUR_TOPBAR_TAG = 78264802;
  5. @implementation RNNStatusBarOptions
  6. - (void)applyOn:(UIViewController *)viewController {
  7. if (self.blur) {
  8. UIView* curBlurView = [viewController.view viewWithTag:BLUR_STATUS_TAG];
  9. if ([self.blur boolValue]) {
  10. if (!curBlurView) {
  11. UIVisualEffectView *blur = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];
  12. blur.frame = [[UIApplication sharedApplication] statusBarFrame];
  13. blur.tag = BLUR_STATUS_TAG;
  14. [viewController.view insertSubview:blur atIndex:0];
  15. }
  16. } else {
  17. if (curBlurView) {
  18. [curBlurView removeFromSuperview];
  19. }
  20. }
  21. }
  22. if (self.style || self.visible) {
  23. if (self.animate) {
  24. [UIView animateWithDuration:[self statusBarAnimationDuration] animations:^{
  25. [viewController setNeedsStatusBarAppearanceUpdate];
  26. }];
  27. } else {
  28. [viewController setNeedsStatusBarAppearanceUpdate];
  29. }
  30. }
  31. }
  32. - (CGFloat)statusBarAnimationDuration {
  33. return [self.animate boolValue] ? kStatusBarAnimationDuration : CGFLOAT_MIN;
  34. }
  35. @end