【发布时间】:2014-07-31 07:16:45
【问题描述】:
我正在使用以下代码混合两个图像:
+ (UIImage *)xxx_blendedImageWithFirstImage:(UIImage *)image
secondImage:(UIImage *)secondImage
renderedInFrame:(CGRect)frame
alpha:(CGFloat)alpha {
UIGraphicsBeginImageContextWithOptions(frame.size, NO, UIScreen.mainScreen.scale);
[image drawInRect:frame];
[secondImage drawInRect:frame blendMode:kCGBlendModeNormal alpha:alpha];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
此代码在IBAction 中调用UISlider,以便在每次滑块位置更改时调用它。这是这段代码的内存占用:
它需要 230 MB,然后由于内存压力而失败。
如何让这段代码正常工作?
【问题讨论】:
标签: ios objective-c memory-management core-graphics