Iphone 绘制多条线
我想画15条水平线,它们之间有20点的间隔。我不明白为什么这个代码不起作用Iphone 绘制多条线,iphone,draw,quartz-2d,lines,Iphone,Draw,Quartz 2d,Lines,我想画15条水平线,它们之间有20点的间隔。我不明白为什么这个代码不起作用 - (void)drawRect:(CGRect)rect { // Drawing code CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor); CGContextSetLineWidth(context
- (void)drawRect:(CGRect)rect
{
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextSetLineWidth(context, 2.0);
for (int i=20;i+=20;i<=20*15) {
CGContextBeginPath(context);
CGContextMoveToPoint(context, 10, i);
CGContextAddLineToPoint(context, 310, i);
CGContextStrokePath(context);
}
}
-(void)drawRect:(CGRect)rect
{
//绘图代码
CGContextRef context=UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(上下文[UIColor redColor].CGColor);
CGContextSetLineWidth(上下文,2.0);
对于(int i=20;i+=20;iYes),for循环应为:
for (int i=20; i<=20*15; i+=20) {
...
}
for(inti=20;iNevermind)。我是个白痴。我把for循环写错了。