diff --git a/YYText/Utility/YYTextAsyncLayer.m b/YYText/Utility/YYTextAsyncLayer.m index e94bc47e..aa8669df 100644 --- a/YYText/Utility/YYTextAsyncLayer.m +++ b/YYText/Utility/YYTextAsyncLayer.m @@ -155,6 +155,9 @@ - (void)_displayAsync:(BOOL)async { CGColorRelease(backgroundColor); return; } + if ((size.width == 0) || (size.height == 0)) { + return; + } UIGraphicsBeginImageContextWithOptions(size, opaque, scale); CGContextRef context = UIGraphicsGetCurrentContext(); if (opaque) { @@ -198,6 +201,9 @@ - (void)_displayAsync:(BOOL)async { }); }); } else { + if ((self.bounds.size.width == 0) || (self.bounds.size.height == 0)) { + return; + } [_sentinel increase]; if (task.willDisplay) task.willDisplay(self); UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, self.contentsScale);