UIGraphicsBeginPDFContextToFile(filePath, CGRectZero, nil);
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, pageSize.width, pageSize.height), nil);
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIFont *bigFont = [UIFont systemFontOfSize:bigFontSize-2];
NSMutableParagraphStyle *paragraphStyleCenter = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyleCenter.lineBreakMode = NSLineBreakByWordWrapping;
paragraphStyleCenter.alignment = NSTextAlignmentCenter;
NSDictionary *bigCenter = @{ NSFontAttributeName: bigFont,NSParagraphStyleAttributeName: paragraphStyleCenter };
CGRect renderingRect = CGRectMake(kMarginInset, kMarginInset -15, (pageSize.width - 2*kMarginInset), stringSize.height);
[tempS drawInRect:renderingRect withAttributes:bigCenter]; //Crash //tempS & renderingRect are valid
当我使用UIGraphicsBeginPDFContextToFile生成PDF时,这只会崩溃,
我对UIView使用相同的代码,它工作正常。
这适用于iOS7