Skip to content

Commit

Permalink
iOS: make RCTSurfaceHostingView have default backgroundColor
Browse files Browse the repository at this point in the history
Summary:
Previously it defaults to using transparent color (iOS default), but when using `RCTSurfaceHostingProxyRootView` we actually manually set to `[UIColor whiteColor]`. However, if the surface is initialized via a different API, the color wasn't set. To avoid confusion and backward incompatibility, let's just set the same background color here.

We can decide in the future if the default color should be transparent instead.

Changelog: [Fixed][iOS] RCTSurfaceHostingView default background color is now consistent with RCTRootView

Reviewed By: RSNara

Differential Revision: D27973748

fbshipit-source-id: c506afbc5629df6647277aa2323f084773c8e760
  • Loading branch information
fkgozali authored and facebook-github-bot committed Apr 24, 2021
1 parent d48c2be commit f314973
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ - (instancetype)initWithBridge:(RCTBridge *)bridge
initialProperties:initialProperties];
[surface start];
if (self = [super initWithSurface:surface sizeMeasureMode:sizeMeasureMode]) {
self.backgroundColor = [UIColor whiteColor];
// Nothing specific to do.
}

RCT_PROFILE_END_EVENT(RCTProfileTagAlways, @"");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ - (instancetype)initWithSurface:(id<RCTSurfaceProtocol>)surface
_surface.delegate = self;
_stage = surface.stage;
[self _updateViews];

// For backward compatibility with RCTRootView, set a color here instead of transparent (OS default).
self.backgroundColor = [UIColor whiteColor];
}

return self;
Expand Down

0 comments on commit f314973

Please sign in to comment.