Skip to content

Commit 73e2d74

Browse files
authored
Merge pull request #303 from jpudysz/feature/thread
fix: set root view background color on ui thread
2 parents e09e959 + a3b7b0f commit 73e2d74

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ios/platform/Platform_iOS.mm

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -173,17 +173,17 @@ - (void)setStatusBarHidden:(bool)isHidden {
173173
}
174174

175175
- (void)setRootViewBackgroundColor:(std::string)color alpha:(float)alpha {
176-
UIViewController *presentedViewController = RCTPresentedViewController();
177-
NSString *colorString = [NSString stringWithUTF8String:color.c_str()];
178-
UIColor *backgroundColor = colorFromHexString(colorString, alpha);
179-
180-
if (backgroundColor == nil) {
181-
NSLog(@"🦄 Unistyles: Couldn't set rootView to %@ color", colorString);
176+
dispatch_async(dispatch_get_main_queue(), ^{
177+
UIViewController *presentedViewController = RCTPresentedViewController();
178+
NSString *colorString = [NSString stringWithUTF8String:color.c_str()];
179+
UIColor *backgroundColor = colorFromHexString(colorString, alpha);
182180

183-
return;
184-
}
181+
if (backgroundColor == nil) {
182+
NSLog(@"🦄 Unistyles: Couldn't set rootView to %@ color", colorString);
185183

186-
dispatch_async(dispatch_get_main_queue(), ^{
184+
return;
185+
}
186+
187187
presentedViewController.view.backgroundColor = backgroundColor;
188188
});
189189
}

0 commit comments

Comments
 (0)