Skip to content

Commit

Permalink
fix(ios): fix border refresh issue (#13729)
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Jan 27, 2023
1 parent 8e1ab35 commit 931ce38
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/TiUIView.m
Expand Up @@ -335,10 +335,17 @@ - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection
{
[super traitCollectionDidChange:previousTraitCollection];

BOOL isInBackground = UIApplication.sharedApplication.applicationState == UIApplicationStateBackground;
BOOL isDifferentColor = [self.traitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection];

if (!isDifferentColor || isInBackground) {
return;
}

// Redraw the border color
id borderColor = [self.proxy valueForKey:@"borderColor"];
if (borderColor != nil) {
[self setBorderColor_:borderColor];
[self refreshBorder:[TiUtils colorValue:borderColor]._color shouldRefreshWidth:NO];
}

// Redraw the view shadow color
Expand Down Expand Up @@ -547,14 +554,22 @@ - (void)setTintColor_:(id)color

- (void)setBorderColor_:(id)color
{
TiColor *ticolor = [TiUtils colorValue:color];
[self refreshBorder:[TiUtils colorValue:color]._color shouldRefreshWidth:YES];
}

- (void)refreshBorder:(UIColor *)color shouldRefreshWidth:(BOOL)shouldRefreshWidth
{
CAShapeLayer *layer = [self borderLayer];
if (layer == self.layer) {
layer.borderWidth = MAX(layer.borderWidth, 1);
layer.borderColor = [ticolor _color].CGColor;
if (shouldRefreshWidth) {
layer.borderWidth = MAX(layer.borderWidth, 1);
}
layer.borderColor = color.CGColor;
} else {
layer.lineWidth = MAX(layer.lineWidth * 2, 1 * 2);
layer.strokeColor = [ticolor _color].CGColor;
if (shouldRefreshWidth) {
layer.lineWidth = MAX(layer.lineWidth * 2, 1 * 2);
}
layer.strokeColor = color.CGColor;
}
}

Expand Down

0 comments on commit 931ce38

Please sign in to comment.