3

Referring to the following image:

enter image description here

. . . . notice how it does not end in a proper point.

I use the following drawing code:

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);

CGContextMoveToPoint(context, self.width - 20, (self.height / 2) - 5);
CGContextAddLineToPoint(context, self.width - 12, self.height / 2);
CGContextStrokePath(context);

CGContextMoveToPoint(context, self.width - 20, (self.height / 2) + 5);
CGContextAddLineToPoint(context, self.width - 12, self.height / 2);
CGContextStrokePath(context);

Is there an easy way to say that a line should end in a point? I know that I could fix this by modifying the coordinates slightly, but I'm curious to learn more.

Jasper Blues
  • 28,258
  • 22
  • 102
  • 185

1 Answers1

2

The lines are not joined, so the CGLineJoin style does not take effect. It should be fine with the following code:

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);

CGContextMoveToPoint(context, self.width - 20, (self.height / 2) - 5);
CGContextAddLineToPoint(context, self.width - 12, self.height / 2);
CGContextAddLineToPoint(context, self.width - 20, self.height / 2 + 5);
CGContextStrokePath(context);
Jasper Blues
  • 28,258
  • 22
  • 102
  • 185
Kirsteins
  • 27,065
  • 8
  • 76
  • 78