Эх сурвалжийг харах

Merge pull request #525 from mariotaku/master

fix #523 error console log
Yaoyuan 8 жил өмнө
parent
commit
cf61fb0b1d

+ 2 - 2
YYText/Utility/YYTextAsyncLayer.m

@@ -157,7 +157,7 @@ static dispatch_queue_t YYTextAsyncLayerGetReleaseQueue() {
             }
             UIGraphicsBeginImageContextWithOptions(size, opaque, scale);
             CGContextRef context = UIGraphicsGetCurrentContext();
-            if (opaque) {
+            if (opaque && context) {
                 CGContextSaveGState(context); {
                     if (!backgroundColor || CGColorGetAlpha(backgroundColor) < 1) {
                         CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
@@ -202,7 +202,7 @@ static dispatch_queue_t YYTextAsyncLayerGetReleaseQueue() {
         if (task.willDisplay) task.willDisplay(self);
         UIGraphicsBeginImageContextWithOptions(self.bounds.size, self.opaque, self.contentsScale);
         CGContextRef context = UIGraphicsGetCurrentContext();
-        if (self.opaque) {
+        if (self.opaque && context) {
             CGSize size = self.bounds.size;
             size.width *= self.contentsScale;
             size.height *= self.contentsScale;