react-native-navigation的迁移库

RNNCustomViewController.m 1.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #import "RNNCustomViewController.h"
  2. @implementation RNNCustomViewController {
  3. NSString* _text;
  4. }
  5. - (instancetype)initWithProps:(NSDictionary *)props {
  6. self = [super init];
  7. _text = props[@"text"];
  8. return self;
  9. }
  10. - (void)viewDidLoad {
  11. [super viewDidLoad];
  12. [self addTestLabel];
  13. [self addDismissModalButton];
  14. [self addNavigationBarButtons];
  15. [[self view] setBackgroundColor:UIColor.whiteColor];
  16. }
  17. - (void)dismissModal {
  18. [self dismissViewControllerAnimated:YES completion:nil];
  19. }
  20. - (void)addDismissModalButton {
  21. UIButton* dismissModalButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.center.x - 70, 300, 140, 50)];
  22. dismissModalButton.backgroundColor = UIColor.systemBlueColor;
  23. dismissModalButton.accessibilityIdentifier = @"EXTERNAL_DISMISS_MODAL_BTN";
  24. [dismissModalButton setTitle:@"Dismiss modal" forState:UIControlStateNormal];
  25. [dismissModalButton addTarget:self action:@selector(dismissModal) forControlEvents:UIControlEventTouchDown];
  26. [self.view addSubview:dismissModalButton];
  27. }
  28. - (void)addTestLabel {
  29. UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
  30. label.textAlignment = NSTextAlignmentCenter;
  31. label.numberOfLines = 2;
  32. label.center = self.view.center;
  33. label.text = _text;
  34. label.accessibilityIdentifier = @"TestLabel";
  35. [self.view addSubview:label];
  36. }
  37. - (void)addNavigationBarButtons {
  38. UIBarButtonItem* rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Right button" style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonPressed)];
  39. rightButton.accessibilityIdentifier = @"EXTERNAL_TOP_BAR_RIGHT_BTN";
  40. self.navigationItem.rightBarButtonItem = rightButton;
  41. }
  42. - (void)rightButtonPressed {
  43. }
  44. @end