Skip to content

Commit

Permalink
Merge pull request #303 from jpudysz/feature/thread
Browse files Browse the repository at this point in the history
fix: set root view background color on ui thread
  • Loading branch information
jpudysz authored Oct 2, 2024
2 parents e09e959 + a3b7b0f commit 73e2d74
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 73e2d74

Please sign in to comment.