Procházet zdrojové kódy

fixed custom top bar alignment

yogevbd před 6 roky
rodič
revize
029440567e
2 změnil soubory, kde provedl 15 přidání a 4 odebrání
  1. 13
    1
      ios/RCCCustomTitleView.m
  2. 2
    3
      ios/RCCViewController.m

+ 13
- 1
ios/RCCCustomTitleView.m Zobrazit soubor

@@ -29,9 +29,10 @@
29 29
         
30 30
         if ([alignment isEqualToString:@"fill"]) {
31 31
             self.frame = frame;
32
-            self.subView.frame = self.frame;
32
+            subView.sizeFlexibility = RCTRootViewSizeFlexibilityNone;
33 33
         } else {
34 34
             self.subView.delegate = self;
35
+            subView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
35 36
         }
36 37
         
37 38
         [self addSubview:subView];
@@ -40,6 +41,17 @@
40 41
     return self;
41 42
 }
42 43
 
44
+- (void)layoutSubviews {
45
+    [super layoutSubviews];
46
+    if ([self.alignment isEqualToString:@"fill"]) {
47
+        [self.subView setFrame:self.bounds];
48
+    }
49
+}
50
+
51
+- (NSString *)alignment {
52
+    return _alignment ? _alignment : @"center";
53
+}
54
+
43 55
 - (void)rootViewDidChangeIntrinsicSize:(RCTRootView *)rootView {
44 56
     if ([self.alignment isEqualToString:@"center"]) {
45 57
         [self setFrame:CGRectMake(0, 0, rootView.intrinsicContentSize.width, rootView.intrinsicContentSize.height)];

+ 2
- 3
ios/RCCViewController.m Zobrazit soubor

@@ -642,12 +642,11 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
642 642
       
643 643
       NSDictionary *initialProps = self.navigatorStyle[@"navBarCustomViewInitialProps"];
644 644
       RCTRootView *reactView = [[RCTRootView alloc] initWithBridge:bridge moduleName:navBarCustomView initialProperties:initialProps];
645
-      reactView.sizeFlexibility = RCTRootViewSizeFlexibilityWidthAndHeight;
646
-        
645
+
647 646
       RCCCustomTitleView *titleView = [[RCCCustomTitleView alloc] initWithFrame:self.navigationController.navigationBar.bounds
648 647
                                                                         subView:reactView
649 648
                                                                       alignment:self.navigatorStyle[@"navBarComponentAlignment"]];
650
-      
649
+
651 650
       self.navigationItem.titleView = titleView;
652 651
       self.navigationItem.titleView.backgroundColor = [UIColor clearColor];
653 652
       self.navigationItem.titleView.clipsToBounds = YES;