使用YYText ,1.0.7在iOS17会遇到如下崩溃 主要原因是UIGraphicsBeginImageContext中的asert引发,而改接口早就标记为API_TO_BE_DEPRECATED,建议使用UIGraphicsImageRenderer替换。 由于YYText早已没有维护,于是fork了一个自己的git进行修正,主要修正逻辑在textAsynLayer

替换为

UIGraphicsImageRenderer *renderer = [[UIGraphicsImageRenderer alloc] initWithSize:size];

UIImage *image = [renderer imageWithActions:^(UIGraphicsImageRendererContext * _Nonnull context) {

if (opaque) {

CGContextSaveGState(context.CGContext); {

if (!backgroundColor || CGColorGetAlpha(backgroundColor) < 1) {

CGContextSetFillColorWithColor(context.CGContext, [UIColor whiteColor].CGColor);

CGContextAddRect(context.CGContext, CGRectMake(0, 0, size.width * scale, size.height * scale));

CGContextFillPath(context.CGContext);

}

if (backgroundColor) {

CGContextSetFillColorWithColor(context.CGContext, backgroundColor);

CGContextAddRect(context.CGContext, CGRectMake(0, 0, size.width * scale, size.height * scale));

CGContextFillPath(context.CGContext);

}

} CGContextRestoreGState(context.CGContext);

CGColorRelease(backgroundColor);

}

task.display(context.CGContext, size, isCancelled);

if (isCancelled()) {

dispatch_async(dispatch_get_main_queue(), ^{

if (task.didDisplay) task.didDisplay(self, NO);

});

return;

}

}];

github地址

具体可参见git@github.com:iamanthonyzhu/YYTextAsynLayer.git

文章来源

评论可见,请评论后查看内容,谢谢!!!
 您阅读本篇文章共花了: