Skip to content

Commit

Permalink
Handle nil backgroundColor in ASTextNode2 #trivial (TextureGroup#841)
Browse files Browse the repository at this point in the history
* Handle nil backgroundColor

* Small improvement
  • Loading branch information
maicki authored and bernieperez committed Apr 25, 2018
1 parent 27bdadc commit e633977
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Source/ASTextNode2.mm
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ - (NSObject *)drawParametersForAsyncLayer:(_ASDisplayLayer *)layer
[self prepareAttributedString:mutableText];

return @{
@"container": copiedContainer,
@"text": mutableText,
@"bgColor": self.backgroundColor
};
@"container": copiedContainer,
@"text": mutableText,
@"bgColor": self.backgroundColor ?: [NSNull null]
};
}

/**
Expand Down Expand Up @@ -467,9 +467,13 @@ + (void)drawRect:(CGRect)bounds withParameters:(NSDictionary *)layoutDict isCanc
}

// Fill background color.
if (bgColor == (id)[NSNull null]) {
bgColor = nil;
}

// They may have already drawn into this context in the pre-context block
// so unfortunately we have to use the normal blend mode, not copy.
if (CGColorGetAlpha(bgColor.CGColor) > 0) {
if (bgColor && CGColorGetAlpha(bgColor.CGColor) > 0) {
[bgColor setFill];
UIRectFillUsingBlendMode(bounds, kCGBlendModeNormal);
}
Expand Down

0 comments on commit e633977

Please sign in to comment.