当我使用UIGraphicsBeginImageContextWithOptions来初始化上下文,然后将图像绘制到该内容时,我会收到 代码如下:
NSString* tempPath = ...;
int count = 5;
CGFloat width = 320;
CGFloat height = 480;
CGFloat scale = 2.0;
CGFloat contextScale = 1.0;
UIGraphicsBeginImageContextWithOptions(CGSizeMake(width * scale, height * scale * count),
NO, contextScale);
int i = 0;
//link picture
while (count > 0) {
NSString* imgName = [NSString stringWithFormat:@"img_%d.jpg", i];
NSString* imgFile = [tempPath stringByAppendingPathComponent:imgName];
UIImage* tempImg = [[UIImage alloc] initWithContentsOfFile:imgFile];
[tempImg drawInRect:CGRectMake(0, height * scale * i,
width * scale, height * scale)];
--count;
++i;
}
UIImage* linkedImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
错误发生在:[tempImg drawInRect:.....]
我无法理解为什么。 帮助我。