react-native-navigation的迁移库

RNNLayoutOptions.m 1.5KB

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