두 점 사이에 선을 그립니다. 여기 내 코드가있다. 하지만 상황에 맞는 메모리 당신은 방법 drawRect:
에 UIView의 서브 클래스 내에서 코드를 호출 할 필요가 0두 개의 다른 점 사이에 선을 그립니다.
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGColorSpaceRef colorspace = CGColorSpaceCreateDeviceRGB();
CGFloat components[] = {0.0, 0.0, 1.0, 1.0};
CGColorRef color = CGColorCreate(colorspace, components);
CGContextSetStrokeColorWithColor(context, color);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 300, 400);
CGContextStrokePath(context);
CGColorSpaceRelease(colorspace);
CGColorRelease(color);
어떤 방법으로 이것을 시도하고 있습니까?, – Vignesh
컨텍스트 메모리는 무엇입니까? 'context' 변수가'nil'이 아니라고 확신합니까? – Alexander
중복 가능성 : http://stackoverflow.com/questions/1878821/how-to-draw-line-between-two-points – Devang