react-native-navigation的迁移库

RNNLayoutOptions.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "RNNLayoutOptions.h"
  2. #import <React/RCTConvert.h>
  3. @implementation RNNLayoutOptions
  4. - (void)applyOn:(UIViewController *)viewController {
  5. if (self.backgroundColor) {
  6. UIColor* screenColor = [RCTConvert UIColor:self.backgroundColor];
  7. viewController.view.backgroundColor = screenColor;
  8. }
  9. }
  10. - (UIInterfaceOrientationMask)supportedOrientations {
  11. NSArray* orientationsArray = [self.orientation isKindOfClass:[NSString class]] ? @[self.orientation] : self.orientation;
  12. NSUInteger supportedOrientationsMask = 0;
  13. if (!orientationsArray || [self.orientation isEqual:@"default"]) {
  14. return [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
  15. } else {
  16. for (NSString* orientation in orientationsArray) {
  17. if ([orientation isEqualToString:@"all"]) {
  18. supportedOrientationsMask = UIInterfaceOrientationMaskAll;
  19. break;
  20. }
  21. if ([orientation isEqualToString:@"landscape"]) {
  22. supportedOrientationsMask = (supportedOrientationsMask | UIInterfaceOrientationMaskLandscape);
  23. }
  24. if ([orientation isEqualToString:@"portrait"]) {
  25. supportedOrientationsMask = (supportedOrientationsMask | UIInterfaceOrientationMaskPortrait);
  26. }
  27. if ([orientation isEqualToString:@"upsideDown"]) {
  28. supportedOrientationsMask = (supportedOrientationsMask | UIInterfaceOrientationMaskPortraitUpsideDown);
  29. }
  30. }
  31. }
  32. return supportedOrientationsMask;
  33. }
  34. @end