Przeglądaj źródła

V2 top bar text font family (#1634)

* screen Background Color iOS

* ios v2 topBarTextFontFamily
bogobogo 7 lat temu
rodzic
commit
7b6148a0e4

+ 1
- 0
lib/ios/RNNNavigationOptions.h Wyświetl plik

@@ -9,6 +9,7 @@
9 9
 @property (nonatomic, strong) NSString* title;
10 10
 @property (nonatomic, strong) NSNumber* screenBackgroundColor;
11 11
 @property (nonatomic, strong) NSString* setTabBadge;
12
+@property (nonatomic, strong) NSString* topBarTextFontFamily;
12 13
 
13 14
 -(instancetype)init;
14 15
 -(instancetype)initWithDict:(NSDictionary *)navigationOptions;

+ 8
- 3
lib/ios/RNNNavigationOptions.m Wyświetl plik

@@ -13,9 +13,9 @@
13 13
 	self.topBarBackgroundColor = [navigationOptions objectForKey:@"topBarBackgroundColor"];
14 14
 	self.statusBarHidden = [navigationOptions objectForKey:@"statusBarHidden"];
15 15
 	self.title = [navigationOptions objectForKey:@"title"];
16
-	self.topBarTextColor = [navigationOptions objectForKey:@"topBarTextColor"];
17 16
 	self.screenBackgroundColor = [navigationOptions objectForKey:@"screenBackgroundColor"];
18 17
 	self.setTabBadge = [navigationOptions objectForKey:@"setTabBadge"];
18
+	self.topBarTextFontFamily = [navigationOptions objectForKey:@"topBarTextFontFamily"];
19 19
 	return self;
20 20
 }
21 21
 
@@ -37,7 +37,13 @@
37 37
 	}
38 38
 	if (self.topBarTextColor) {
39 39
 		UIColor* textColor = [RCTConvert UIColor:self.topBarTextColor];
40
-		viewController.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:textColor};
40
+		NSMutableDictionary* navigationBarTitleTextAttributes = [NSMutableDictionary dictionaryWithDictionary:@{NSForegroundColorAttributeName: textColor}];
41
+		if (self.topBarTextFontFamily) {
42
+			[navigationBarTitleTextAttributes addEntriesFromDictionary:@{NSFontAttributeName: [UIFont fontWithName:self.topBarTextFontFamily size:20]}];
43
+		}
44
+		viewController.navigationController.navigationBar.titleTextAttributes = navigationBarTitleTextAttributes;
45
+	} else if (self.topBarTextFontFamily){
46
+		viewController.navigationController.navigationBar.titleTextAttributes = @{NSFontAttributeName: [UIFont fontWithName:self.topBarTextFontFamily size:20]};
41 47
 	}
42 48
 	if (self.screenBackgroundColor) {
43 49
 		UIColor* screenColor = [RCTConvert UIColor:self.screenBackgroundColor];
@@ -55,5 +61,4 @@
55 61
 
56 62
 
57 63
 
58
-
59 64
 @end

+ 4
- 2
playground/src/containers/OptionsScreen.js Wyświetl plik

@@ -12,7 +12,8 @@ import Navigation from 'react-native-navigation';
12 12
 class OptionsScreen extends Component {
13 13
   static navigationOptions = {
14 14
     title: 'Static Title',
15
-    topBarBackgroundColor: "red"
15
+    topBarBackgroundColor: "red",
16
+    topBarTextFontFamily: "HelveticaNeue-Italic"
16 17
   }
17 18
 
18 19
   constructor(props) {
@@ -34,7 +35,8 @@ class OptionsScreen extends Component {
34 35
     Navigation.setOptions(this.props.containerId, {
35 36
       title: 'Dynamic Title',
36 37
       topBarTextColor: '#00FFFF',
37
-      topBarBackgroundColor: 'green'
38
+      topBarBackgroundColor: 'green',
39
+      topBarTextFontFamily: "HelveticaNeue-CondensedBold"
38 40
     });
39 41
   }
40 42
 }