[英]Draw lines without the -(void)drawRect:(CGRect)rect method?
I want to make a chart inside an UIView. 我想在UIView中创建一个图表。 Something like this:
像这样:
Is there an easier way to draw the lines than using this method: 有没有比使用此方法更容易绘制线条的方法:
-(void)drawRect:(CGRect)rect{
[super drawRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
// Draw them with a 2.0 stroke width so they are a bit more visible.
CGContextSetLineWidth(context, 2.0f);
CGContextMoveToPoint(context, 0.0f, 0.0f); //start at this point
CGContextAddLineToPoint(context, 20.0f, 20.0f); //draw to this point
// and now draw the Path!
CGContextStrokePath(context);
}
? ?
Why don't you try UIBezierPath
a high-level implementation from Apple. 您为什么不尝试
UIBezierPath
来自Apple的高级实现。
Simply refer UIBezierPath - Apple Doc for more info 只需参考UIBezierPath-Apple Doc了解更多信息
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.