Skip to content

Commit 044702a

Browse files
committed
Update iOS to allow custom name for the splash image. This allows to re-use the image from LaunchScreen.xib and actually uses xcassets type image that has variants for all screen densities (1x, 2x, 3x).
1 parent bb32bf9 commit 044702a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

ios/RCTSplashScreen/RCTSplashScreen/RCTSplashScreen.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ typedef NS_ENUM(NSInteger, RCTCameraAspect) {
1010
};
1111

1212
+ (void)open:(RCTRootView *)v;
13+
+ (void)open:(RCTRootView *)v withImageNamed:(NSString *)imgName;
1314

1415
@end

ios/RCTSplashScreen/RCTSplashScreen/RCTSplashScreen.m

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,27 @@ @implementation RCTSplashScreen
1111

1212
RCT_EXPORT_MODULE(SplashScreen)
1313

14+
1415
+ (void)open:(RCTRootView *)v {
16+
[RCTSplashScreen open:v withImageNamed:@"splash"];
17+
}
18+
19+
20+
+ (void)open:(RCTRootView *)v withImageNamed:(NSString *)imageName {
1521
rootView = v;
22+
1623
UIImageView *view = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
17-
view.image = [UIImage imageNamed:@"splash"];
24+
25+
view.image = [UIImage imageNamed:imageName];
1826

1927
[[NSNotificationCenter defaultCenter] removeObserver:rootView name:RCTContentDidAppearNotification object:rootView];
2028

2129
[rootView setLoadingView:view];
2230
}
2331

32+
33+
34+
2435
RCT_EXPORT_METHOD(close:(NSInteger *)animationType
2536
duration:(NSInteger)duration
2637
delay:(NSInteger)delay) {

0 commit comments

Comments
 (0)