Просмотр исходного кода

[iOS] Added ability to set static(root) background image (#1366)

[iOS] Added ability to set static(root) background image
Ruslan.V 7 лет назад
Родитель
Сommit
26dbb1b6ba
2 измененных файлов: 10 добавлений и 1 удалений
  1. 2
    1
      docs/styling-the-navigator.md
  2. 8
    0
      ios/RCCViewController.m

+ 2
- 1
docs/styling-the-navigator.md Просмотреть файл

@@ -63,7 +63,8 @@ this.props.navigator.setStyle({
63 63
   
64 64
   disabledBackGesture: false, // default: false. Disable the back gesture (swipe gesture) in order to pop the top screen. 
65 65
   screenBackgroundImageName: '<name of image in Images.xcassets>', // Optional. default screen background image.
66
-  
66
+  rootBackgroundImageName: '<name of image in Images.xcassets>', // Static while you transition between screens. Works best with screenBackgroundColor: 'transparent'
67
+
67 68
   navBarButtonFontSize: 20, // Change font size nav bar buttons (eg. the back button) (remembered across pushes)
68 69
   navBarButtonFontWeight: '500', // Change font weight nav bar buttons (eg. the back button) (remembered across pushes)
69 70
 

+ 8
- 0
ios/RCCViewController.m Просмотреть файл

@@ -96,6 +96,14 @@ const NSInteger TRANSPARENT_NAVBAR_TAG = 78264803;
96 96
     [[RCCManager sharedInstance] registerController:controller componentId:componentId componentType:type];
97 97
   }
98 98
   
99
+  // set background image at root level
100
+  NSString *rootBackgroundImageName = props[@"style"][@"rootBackgroundImageName"];
101
+  if (rootBackgroundImageName) {
102
+    UIImage *image = [UIImage imageNamed: rootBackgroundImageName];
103
+    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
104
+    [controller.view insertSubview:imageView atIndex:0];
105
+  }
106
+  
99 107
   return controller;
100 108
 }
101 109