Skip to content

Commit

Permalink
fix: set root view background color on ui thread
Browse files Browse the repository at this point in the history
  • Loading branch information
jpudysz committed Oct 2, 2024
1 parent e09e959 commit a3b7b0f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions ios/platform/Platform_iOS.mm
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,17 @@ - (void)setStatusBarHidden:(bool)isHidden {
}

- (void)setRootViewBackgroundColor:(std::string)color alpha:(float)alpha {
UIViewController *presentedViewController = RCTPresentedViewController();
NSString *colorString = [NSString stringWithUTF8String:color.c_str()];
UIColor *backgroundColor = colorFromHexString(colorString, alpha);

if (backgroundColor == nil) {
NSLog(@"🦄 Unistyles: Couldn't set rootView to %@ color", colorString);
dispatch_async(dispatch_get_main_queue(), ^{
UIViewController *presentedViewController = RCTPresentedViewController();
NSString *colorString = [NSString stringWithUTF8String:color.c_str()];
UIColor *backgroundColor = colorFromHexString(colorString, alpha);

return;
}
if (backgroundColor == nil) {
NSLog(@"🦄 Unistyles: Couldn't set rootView to %@ color", colorString);

dispatch_async(dispatch_get_main_queue(), ^{
return;
}

presentedViewController.view.backgroundColor = backgroundColor;
});
}
Expand Down

0 comments on commit a3b7b0f

Please sign in to comment.