Commit 21f54188 authored by Jérôme Lebel's avatar Jérôme Lebel Committed by Commit Bot

[iOS] GradientView layer is not initialized

The -[GradientView updateColors] needs to be called at least once, to
initialize correctly the gradient colors.

Before:
https://drive.google.com/open?id=1WJnG8ahbljpr0hSR8fut8ezGyIJ1i9s6
After:
https://drive.google.com/open?id=1y0xTlrpu3ssvrlw7Kx05d5lqK56a1-Ko
(the blue background was set just for the screenshots)

Bug: 971989
Change-Id: I08c1fe12f5b142fde038da9b779a7399f1771f3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2133937
Commit-Queue: Jérôme Lebel <jlebel@chromium.org>
Auto-Submit: Jérôme Lebel <jlebel@chromium.org>
Reviewed-by: default avatarNohemi Fernandez <fernandex@chromium.org>
Cr-Commit-Position: refs/heads/master@{#757032}
parent 4343b16e
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
self = [super initWithFrame:CGRectZero]; self = [super initWithFrame:CGRectZero];
if (self) { if (self) {
self.userInteractionEnabled = NO; self.userInteractionEnabled = NO;
[self updateColors];
} }
return self; return self;
} }
...@@ -31,8 +32,7 @@ ...@@ -31,8 +32,7 @@
return base::mac::ObjCCastStrict<CAGradientLayer>(self.layer); return base::mac::ObjCCastStrict<CAGradientLayer>(self.layer);
} }
- (void)traitCollectionDidChange: - (void)traitCollectionDidChange:(UITraitCollection*)previousTraitCollection {
(nullable UITraitCollection*)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection]; [super traitCollectionDidChange:previousTraitCollection];
if (@available(iOS 13, *)) { if (@available(iOS 13, *)) {
if ([self.traitCollection if ([self.traitCollection
...@@ -54,7 +54,7 @@ ...@@ -54,7 +54,7 @@
self.gradientLayer.colors = @[ self.gradientLayer.colors = @[
(id)[UIColor.cr_systemBackgroundColor colorWithAlphaComponent:0].CGColor, (id)[UIColor.cr_systemBackgroundColor colorWithAlphaComponent:0].CGColor,
(id)UIColor.cr_systemBackgroundColor.CGColor (id)UIColor.cr_systemBackgroundColor.CGColor,
]; ];
[CATransaction commit]; [CATransaction commit];
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment