react-native-navigation的迁移库

RNNUIBarButtonItem.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #import <Foundation/Foundation.h>
  2. #import <UIKit/UIKit.h>
  3. #import "RNNUIBarButtonItem.h"
  4. #import "RCTConvert+UIBarButtonSystemItem.h"
  5. @implementation RNNUIBarButtonItem
  6. -(instancetype)init:(NSString*)buttonId withIcon:(UIImage*)iconImage {
  7. self = [super initWithImage:iconImage style:UIBarButtonItemStylePlain target:nil action:nil];
  8. self.buttonId = buttonId;
  9. return self;
  10. }
  11. -(instancetype)init:(NSString*)buttonId withTitle:(NSString*)title {
  12. self = [super initWithTitle:title style:UIBarButtonItemStylePlain target:nil action:nil];
  13. self.buttonId = buttonId;
  14. return self;
  15. }
  16. -(instancetype)init:(NSString*)buttonId withCustomView:(RCTRootView *)reactView {
  17. self = [super initWithCustomView:reactView];
  18. reactView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
  19. reactView.delegate = self;
  20. reactView.backgroundColor = [UIColor clearColor];
  21. self.buttonId = buttonId;
  22. return self;
  23. }
  24. -(instancetype)init:(NSString*)buttonId withSystemItem:(NSString *)systemItemName {
  25. UIBarButtonSystemItem systemItem = [RCTConvert UIBarButtonSystemItem:systemItemName];
  26. self = [super initWithBarButtonSystemItem:systemItem target:nil action:nil];
  27. self.buttonId = buttonId;
  28. return self;
  29. }
  30. - (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView {
  31. CGSize size = rootView.intrinsicContentSize;
  32. rootView.frame = CGRectMake(0, 0, size.width, size.height);
  33. self.width = size.width;
  34. }
  35. @end