react-native-navigation的迁移库

RNNLayoutOptions.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.orientation = dict[@"orientation"];
  9. return self;
  10. }
  11. - (UIInterfaceOrientationMask)supportedOrientations {
  12. NSArray* orientationsArray = [self.orientation isKindOfClass:[NSString class]] ? @[self.orientation] : self.orientation;
  13. NSUInteger supportedOrientationsMask = 0;
  14. if (!orientationsArray || [self.orientation isEqual:@"default"]) {
  15. return [[UIApplication sharedApplication] supportedInterfaceOrientationsForWindow:[[UIApplication sharedApplication] keyWindow]];
  16. } else {
  17. for (NSString* orientation in orientationsArray) {
  18. if ([orientation isEqualToString:@"all"]) {
  19. supportedOrientationsMask = UIInterfaceOrientationMaskAll;
  20. break;
  21. }
  22. if ([orientation isEqualToString:@"landscape"]) {
  23. supportedOrientationsMask = (supportedOrientationsMask | UIInterfaceOrientationMaskLandscape);
  24. }
  25. if ([orientation isEqualToString:@"portrait"]) {
  26. supportedOrientationsMask = (supportedOrientationsMask | UIInterfaceOrientationMaskPortrait);
  27. }
  28. if ([orientation isEqualToString:@"upsideDown"]) {
  29. supportedOrientationsMask = (supportedOrientationsMask | UIInterfaceOrientationMaskPortraitUpsideDown);
  30. }
  31. }
  32. }
  33. return supportedOrientationsMask;
  34. }
  35. @end