react-native-navigation的迁移库

RCCCustomBarButtonItem.m 1.0KB

12345678910111213141516171819202122232425262728293031
  1. #import <React/RCTRootView.h>
  2. #import <React/RCTRootViewDelegate.h>
  3. #import "RCCCustomBarButtonItem.h"
  4. @interface RCCCustomBarButtonItem () <RCTRootViewDelegate>
  5. @property (nonnull, nonatomic, strong, readwrite) RCTRootView *reactView;
  6. @end
  7. @implementation RCCCustomBarButtonItem
  8. - (instancetype)initWithComponentName:(NSString *__nonnull)component passProps:(NSDictionary *)passProps bridge:(RCTBridge *__nonnull)bridge {
  9. RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:component initialProperties:passProps];
  10. self = [super initWithCustomView:reactView];
  11. if (self) {
  12. reactView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
  13. reactView.delegate = self;
  14. reactView.backgroundColor = [UIColor clearColor];
  15. }
  16. return self;
  17. }
  18. - (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView {
  19. CGSize size = rootView.intrinsicContentSize;
  20. rootView.frame = CGRectMake(0, 0, size.width, size.height);
  21. self.width = size.width;
  22. }
  23. @end