浏览代码

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

[iOS] Added ability to set static(root) background image
Ruslan.V 7 年前
父节点
当前提交
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