objective-c - 如何使用自定义 View 设置核心绘图的绘图面积

标签 objective-c ios core-plot

我正在使用核心图绘制图。我正在尝试在绘图区域上绘制图形,但是它包含白色背景。但是我想用自己的背景画图。这是我的代码。

CGRect frame = [self.hostingView bounds];
self.graph = [[[CPTXYGraph alloc] initWithFrame:frame] autorelease];

// Add some padding to the graph, with more at the bottom for axis labels.
self.graph.plotAreaFrame.paddingTop = 10.0f;
self.graph.plotAreaFrame.paddingRight = 10.0f;
self.graph.plotAreaFrame.paddingBottom = 25.0f;
self.graph.plotAreaFrame.paddingLeft = 30.0f;
self.graph.plotAreaFrame.plotArea.fill=[(CPTFill *)[CPTFill alloc] initWithColor:    [CPTColor colorWithComponentRed:0.8 green:0.8 blue:0.8 alpha:1.0]];

// Tie the graph we've created with the hosting view.
self.hostingView.hostedGraph = self.graph;
}

在上面的代码中,我尝试更改颜色,但是我想为y轴上的每个刻度绘制水平虚线。

最佳答案

要绘制水平线,请为y轴设置majorGridLineStyle和/或minorGridLineStyle以分别从主要刻度线和次要刻度线绘制线条。使用线型的dashPatternpatternPhase属性来控制点样。有关如何使用这些线型属性的详细信息,请参见Apple的Quartz 2D docs

关于objective-c - 如何使用自定义 View 设置核心绘图的绘图面积,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8758377/

相关文章:

c# - C# 开发人员可以从 Objective-C 中学到什么?

objective-c - 在标准实践中,谁拥有 NSWindowController?

iOS 7 状态栏问题

ios - 在 iOS 上提高 mp3 音量

ios subview 在模拟器中出现颠倒

objective-c - 有没有 Objective-C 网络爬虫框架?

objective-c - 如何在ARC下自动释放未返回的对象

ios - quickblox - 删除私有(private)(1 对 1)聊天

javascript - 实时图表和 iPad 应用程序

performance - 提高 Quartz2D 绘图性能