瀏覽代碼

Fix topBar title alignment on iOS (#5602)

Fix topBar title alignment
Yogev Ben David 5 年之前
父節點
當前提交
094b9a7ef1
共有 3 個文件被更改,包括 8 次插入18 次删除
  1. 5
    16
      lib/ios/RNNComponentPresenter.m
  2. 1
    1
      lib/ios/RNNStackPresenter.m
  3. 2
    1
      lib/ios/RNNTitleViewHelper.m

+ 5
- 16
lib/ios/RNNComponentPresenter.m 查看文件

@@ -46,11 +46,11 @@
46 46
 	[viewController setStatusBarStyle:[withDefault.statusBar.style getWithDefaultValue:@"default"] animated:[withDefault.statusBar.animate getWithDefaultValue:YES]];
47 47
 	[viewController setBackButtonVisible:[withDefault.topBar.backButton.visible getWithDefaultValue:YES]];
48 48
 	[viewController setInterceptTouchOutside:[withDefault.overlay.interceptTouchOutside getWithDefaultValue:YES]];
49
-	
49
+
50 50
 	if (withDefault.layout.backgroundColor.hasValue) {
51 51
 		[viewController setBackgroundColor:withDefault.layout.backgroundColor.get];
52 52
 	}
53
-	
53
+
54 54
 	if (withDefault.topBar.searchBar.hasValue) {
55 55
 		BOOL hideNavBarOnFocusSearchBar = YES;
56 56
 		if (withDefault.topBar.hideNavBarOnFocusSearchBar.hasValue) {
@@ -58,7 +58,7 @@
58 58
 		}
59 59
 		[viewController setSearchBarWithPlaceholder:[withDefault.topBar.searchBarPlaceholder getWithDefaultValue:@""] hideNavBarOnFocusSearchBar:hideNavBarOnFocusSearchBar];
60 60
 	}
61
-	
61
+
62 62
 	[self setTitleViewWithSubtitle:withDefault];
63 63
 }
64 64
 
@@ -153,8 +153,6 @@
153 153
 		rootView.passThroughTouches = !options.overlay.interceptTouchOutside.get;
154 154
 	}
155 155
 
156
-	[self setTitleViewWithSubtitle:withDefault];
157
-
158 156
 	if (options.topBar.title.component.name.hasValue) {
159 157
 		[self setCustomNavigationTitleView:options perform:nil];
160 158
 	} else {
@@ -162,6 +160,8 @@
162 160
 		_customTitleView = nil;
163 161
 	}
164 162
 
163
+	[self setTitleViewWithSubtitle:withDefault];
164
+	
165 165
 	if (options.topBar.backButton.hasValue) {
166 166
 		UIViewController *lastViewControllerInStack = viewController.navigationController.viewControllers.count > 1 ? viewController.navigationController.viewControllers[viewController.navigationController.viewControllers.count - 2] : viewController.navigationController.topViewController;
167 167
 	    RNNNavigationOptions * resolvedOptions	= (RNNNavigationOptions *) [[currentOptions overrideOptions:options] withDefault:[self defaultOptions]];
@@ -208,17 +208,6 @@
208 208
 			[_titleViewHelper setSubtitleOptions:options.topBar.subtitle];
209 209
 		}
210 210
 
211
-		[_titleViewHelper setup];
212
-	} else {
213
-		_titleViewHelper = [[RNNTitleViewHelper alloc] initWithTitleViewOptions:options.topBar.title subTitleOptions:options.topBar.subtitle viewController:self.boundViewController];
214
-		
215
-		if (options.topBar.title.text.hasValue) {
216
-			[_titleViewHelper setTitleOptions:options.topBar.title];
217
-		}
218
-		if (options.topBar.subtitle.text.hasValue) {
219
-			[_titleViewHelper setSubtitleOptions:options.topBar.subtitle];
220
-		}
221
-		
222 211
 		[_titleViewHelper setup];
223 212
 	}
224 213
 }

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

@@ -57,7 +57,7 @@
57 57
 	RNNNavigationOptions *withDefault = [options withDefault:[self defaultOptions]];
58 58
 	RNNStackController* navigationController = self.boundViewController;
59 59
 	[navigationController setTopBarBackgroundColor:[withDefault.topBar.background.color getWithDefaultValue:nil]];
60
-	[navigationController setNavigationBarFontFamily:[withDefault.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.title.fontSize getWithDefaultValue:nil] fontWeight:[withDefault.topBar.title.fontWeight getWithDefaultValue:nil] color:[withDefault.topBar.title.color getWithDefaultValue:[UIColor blackColor]]];
60
+	[navigationController setNavigationBarFontFamily:[withDefault.topBar.title.fontFamily getWithDefaultValue:nil] fontSize:[withDefault.topBar.title.fontSize getWithDefaultValue:nil] fontWeight:[withDefault.topBar.title.fontWeight getWithDefaultValue:nil] color:[withDefault.topBar.title.color getWithDefaultValue:nil]];
61 61
 	[navigationController setNavigationBarLargeTitleVisible:[withDefault.topBar.largeTitle.visible getWithDefaultValue:NO]];
62 62
 }
63 63
 

+ 2
- 1
lib/ios/RNNTitleViewHelper.m 查看文件

@@ -143,6 +143,7 @@
143 143
 	CGRect labelframe = titleLabel.frame;
144 144
 	labelframe.size = labelSize;
145 145
 	titleLabel.frame = labelframe;
146
+	[titleLabel sizeToFit];
146 147
 	
147 148
 	if (!self.subtitle) {
148 149
 		titleLabel.center = self.titleView.center;
@@ -153,7 +154,7 @@
153 154
 		titleLabel.textColor = color;
154 155
 	}
155 156
 	
156
-	[titleLabel sizeToFit];
157
+	
157 158
 	[self.titleView addSubview:titleLabel];
158 159
 	
159 160
 	return titleLabel;