gpt4 book ai didi

ios - 核心剧情: Creating a CPTImage with imageWithCGImage

转载 作者:行者123 更新时间:2023-11-29 02:29:54 25 4
gpt4 key购买 nike

我正在尝试在核心图中创建一个带有渐变的条形图。我有以下代码:

UIImage *img = [UIImage imageNamed:@"orange_bar_graph"];

CPTImage *image = [CPTImage imageWithCGImage:img.CGImage];
image.tiled = NO;
CPTFill *areaFill = [CPTFill fillWithImage:image];

CPTBarPlot *plotOne = [[CPTBarPlot alloc] init];
plotOne.fill = areaFill;
plotOne.identifier = identifer[@"plotOne"];

然而,当我运行该应用程序时,它只显示条形图的轮廓,而未显示填充图像: enter image description here

如果我放置断点,它表明图像已成功创建并且变量 areaFill 不为零。

我不久前发了一篇帖子,其中我使用了类似的代码。在这里我使用 imageForPNGFile 但在此处尝试时它只是返回 nil:Core Plot Gradient bars

但是我似乎无法让它在这里工作。

编辑:

我刚刚在 iPad 2 模拟器上运行了它,它按预期运行。但是在 iPad Air 模拟器上运行时它不起作用。

最佳答案

设置图像的比例

CPTImage *image = [CPTImage imageWithCGImage:img.CGImage scale:img.scale];

如果您使用的是最新的 Core Plot 代码(1.5.1 版本之后),您可以直接加载图像:

CPTImage *image = [CPTImage imageNamed:@"orange_bar_graph"];

关于ios - 核心剧情: Creating a CPTImage with imageWithCGImage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27036343/

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