Closed GetToSet closed 4 years ago
Hey @GetToSet,
thanks for the investigation and fixing the bug. Great work 👍
Additionally, I've just tweaked the implementation a little bit (see https://github.com/SvenTiigi/WhatsNewKit/commit/eb588f26dd6410333a61d8e069a24d2c64eaef89)
From
if size.width == 0 && size.height == 0 {
return nil
}
To
guard size != .zero else {
return nil
}
I found a weird error log regarding invalid
CGContext
when using this framework.After some investigation, I found its cause:
CompletionButton
is redrawing its background image attraitCollectionDidChange
, which is called beforelayoutSubviews
. At early initialization stage, the button may have empty frame with both height and width set to 0, resulting "invalid context error" when drawing background image.This commit adds extra check to prevent creating context when frame is empty, delaying the creation of background image to
layoutSubviews
call.