gpt4 book ai didi

ios - 虚拟机 : CG raster Data memory keep growing

转载 作者:可可西里 更新时间:2023-11-01 06:14:39 26 4
gpt4 key购买 nike

所以我正在尝试制作一个应用程序,让用户可以更改 UIImage 的颜色,因为我正在使用我发现的这个功能

 - (UIImage *)imageWithTintColor:(UIColor *)color fraction:(CGFloat)fraction
{
if (color)
{
UIImage *image;
if ([UIScreen instancesRespondToSelector:@selector(scale)])
{
UIGraphicsBeginImageContextWithOptions([self size], NO, 0.f);
}
else
{
UIGraphicsBeginImageContext([self size]);
}

CGRect rect = CGRectZero;
rect.size = [self size];
[color set];
UIRectFill(rect);

[self drawInRect:rect blendMode:kCGBlendModeDestinationIn alpha:1.0];

if (fraction > 0.0)
{
[self drawInRect:rect blendMode:kCGBlendModeSourceAtop alpha:fraction];
}
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
return self;
}

一切正常,但 CG 光栅数据在内存中增长 enter image description here

最佳答案

我发现了问题,这是我的错误逻辑,我使用 2 个 View ,一个用于显示,一个用于处理 ex:resize、move、rotate。每次我都将 Subview 添加到其中一个需要一次只持有 1 个的地方,一个简单的:

  for (UIView *view in 2cndView.subviews)
{
[view removeFromSuperview];
}

对我有用

关于ios - 虚拟机 : CG raster Data memory keep growing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27647381/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com