浏览代码

V2 topBarTransparent (#2252)

yogevbd 7 年前
父节点
当前提交
4f9a5c6fed

+ 7
- 0
lib/ios/RNNNavigationOptions.m 查看文件

@@ -110,6 +110,13 @@ const NSInteger BLUR_TOPBAR_TAG = 78264802;
110 110
 			viewController.navigationController.navigationBar.translucent = [self.topBar.translucent boolValue];
111 111
 		}
112 112
 		
113
+		if (self.topBar.transparent) {
114
+			[viewController.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
115
+			viewController.navigationController.navigationBar.shadowImage = [UIImage new];
116
+			UIView *transparentView = [[UIView alloc] initWithFrame:CGRectZero];
117
+			[viewController.navigationController.navigationBar insertSubview:transparentView atIndex:0];
118
+		}
119
+		
113 120
 		if (self.topBar.noBorder) {
114 121
 			if ([self.topBar.noBorder boolValue]) {
115 122
 				viewController.navigationController.navigationBar

+ 1
- 0
lib/ios/RNNTopBarOptions.h 查看文件

@@ -12,6 +12,7 @@ extern const NSInteger BLUR_TOPBAR_TAG;
12 12
 @property (nonatomic, strong) NSNumber* hideOnScroll;
13 13
 @property (nonatomic, strong) NSNumber* buttonColor;
14 14
 @property (nonatomic, strong) NSNumber* translucent;
15
+@property (nonatomic, strong) NSNumber* transparent;
15 16
 @property (nonatomic, strong) NSNumber* textFontSize;
16 17
 @property (nonatomic, strong) NSNumber* noBorder;
17 18
 @property (nonatomic, strong) NSNumber* blur;

+ 1
- 0
lib/ios/RNNTopBarOptions.m 查看文件

@@ -19,6 +19,7 @@
19 19
 	self.buttonColor = [topBarOptions valueForKey:@"buttonColor"];
20 20
 	self.blur = [topBarOptions valueForKey:@"blur"];
21 21
 	self.translucent = [topBarOptions valueForKey:@"translucent"];
22
+	self.transparent = [topBarOptions valueForKey:@"transparent"];
22 23
 	self.noBorder = [topBarOptions valueForKey:@"noBorder"];
23 24
 	self.animateHide =[topBarOptions valueForKey:@"animateHide"];
24 25
 	

+ 10
- 0
lib/ios/ReactNativeNavigationTests/RNNRootViewControllerTest.m 查看文件

@@ -156,6 +156,16 @@
156 156
 	XCTAssertFalse(self.uut.navigationController.navigationBar.translucent);
157 157
 }
158 158
 
159
+-(void)testTopBarTransparent {
160
+	NSNumber* topBarTransparentInput = @(0);
161
+	self.options.topBar.transparent = topBarTransparentInput;
162
+	__unused RNNNavigationController* nav = [[RNNNavigationController alloc] initWithRootViewController:self.uut];
163
+	[self.uut viewWillAppear:false];
164
+	XCTAssertNotNil(self.uut.navigationController.navigationBar.shadowImage);
165
+	XCTAssertNotNil([self.uut.navigationController.navigationBar backgroundImageForBarMetrics:UIBarMetricsDefault]);
166
+	XCTAssertTrue(CGRectEqualToRect(self.uut.navigationController.navigationBar.subviews.firstObject.frame, CGRectZero));
167
+}
168
+
159 169
 -(void)testTabBadge {
160 170
 	NSString* tabBadgeInput = @"5";
161 171
 	self.options.tabBar.tabBadge = tabBadgeInput;