[英]How to write text on graph x and y-axis intervals points?
我使用NSObject类和CGContext方法开发了图形。 以下代码以X和Y轴间隔动态显示,
CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);
CGContextSetLineWidth(ctx, 2.0);
CGContextMoveToPoint(ctx, 30.0, 200.0);
CGContextAddLineToPoint(ctx, 30.0, 440.0);
for(float y = 400.0; y >= 200.0; y-=30)
{
CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);
CGContextMoveToPoint(ctx, 28, y);
CGContextAddLineToPoint(ctx, 32, y);
CGContextStrokePath(ctx);
//CGContextClosePath(ctx);
}
CGContextMoveToPoint(ctx, 10, 420.0);
CGContextAddLineToPoint(ctx, 320, 420.0);
//CGContextAddLineToPoint(ctx, 320.0, 420.0);
//CGContextStrokePath(ctx);
for(float x = 60.0; x <= 260.0; x+=30)
{
CGContextSetRGBStrokeColor(ctx, 2.0, 2.0, 2.0, 1.0);
CGContextMoveToPoint(ctx, x, 418.0);
CGContextAddLineToPoint(ctx, x, 422.0);
CGContextStrokePath(ctx);
CGContextClosePath(ctx);
}
我想在间隔附近的X轴和Y轴行上写动态文本(例如X轴表示每周的天数,Y轴表示某点东西)吗? 谢谢。
您可能想看看Core Plot框架。
上面提供的链接Steve具有源代码。 在“来源”标签下
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.