我不相信由Rahul發佈的答案將工作,因爲React Native編碼導航欄外觀變化的方式。
我做了一個小小的補丁,可以讓你的代碼工作。我可以提交這個反應本地人,但還沒決定:
--- a/node_modules/react-native/React/Views/RCTWrapperViewController.m
+++ b/node_modules/react-native/React/Views/RCTWrapperViewController.m
@@ -115,9 +115,11 @@ static UIView *RCTFindNavBarShadowViewInView(UIView *view)
bar.barTintColor = _navItem.barTintColor;
bar.tintColor = _navItem.tintColor;
bar.translucent = _navItem.translucent;
- bar.titleTextAttributes = _navItem.titleTextColor ? @{
- NSForegroundColorAttributeName: _navItem.titleTextColor
- } : nil;
+ if (_navItem.titleTextColor != nil) {
+ NSMutableDictionary *newAttributes = bar.titleTextAttributes ? bar.titleTextAttributes.mutableCopy : [NSMutableDictionary new];
+ [newAttributes setObject:_navItem.titleTextColor forKey:NSForegroundColorAttributeName];
+ bar.titleTextAttributes = newAttributes;
+ }
RCTFindNavBarShadowViewInView(bar).hidden = _navItem.shadowHidden;
有了這個補丁,你應該能夠做到以下幾點(SWIFT):
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: UIFont(name:"Avenir-Light", size: 22.0) as Any]
是你能解決這個? –