Rather than using CGContext I would recommend switching to using a CAShapeLayer. I used this approach in one of my apps like this:
//call this on every drawRect: call.
-(void)makeLineLayer:(CALayer *)layer{
CAShapeLayer *line = [CAShapeLayer layer];
UIBezierPath *linePath=[UIBezierPath bezierPath];
[linePath moveToPoint:self.lineStart];
[linePath addLineToPoint:self.lineEnd];
[linePath setLineWidth:60.0];
line.path=linePath.CGPath;
line.fillColor = nil;
line.opacity = 1.0;
[layer addSublayer:line];
}
This will give you the line between the two points. From Here I would recommend adding a CALayer
to the CAShapeLayer
and set its contents
property to your image. Here is a link to an article describing how to tile an image in a CALayer. Then you wold need to calculate the angle of the CAShapeLayer
and rotate the CALayer
by that angle.