我使用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轴表示每件事的某些内容)?
谢谢。