我想在表格视图单元格中绘制线条,以便我可以在单个单元格中放置文本字段和开关。我增加了单元格的高度。如何在单元格中绘制线条?
我有一个UIView的子类,其中包含以下代码:
//Get the CGContext from this view
CGContextRef context = UIGraphicsGetCurrentContext();
//Set the stroke (pen) color
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
//Set the width of the pen mark
CGContextSetLineWidth(context, 1.0);
// Draw a line
//Start at this point
CGContextMoveToPoint(context, 10.0, 30.0);
//Give instructions to the CGContext
//(move "pen" around the screen)
CGContextAddLineToPoint(context, 310.0, 30.0);
//Draw it
CGContextStrokePath(context);
我有一个使用分组表格样式的tableViewController。在cellForRowAtIndexPath中,我有以下代码:
//code to add textfield
DrawLineView *drawLine = [[DrawLineView alloc]init];
[cell addSubview:drawLine];
//code add switch
但是它没有画出任何线条。我不能使用两个不同的单元格。我必须请帮助我。这是我第一次处理 iPhone 上的图形。谢谢。