title: drawRect - Draw Star
body: <p>I am drawing annotations on a view. The approach i am using to draw star is below.</p>
  
  <pre><code>-(void)drawRect:(CGRect)rect {
  
  CGContextRef context = UIGraphicsGetCurrentContext();
  CGContextSetLineWidth(context, 2.0);
  CGFloat xCenter = rect.size.width / 2;
  CGFloat yCenter = rect.size.height / 2;
  
  float width;
  if(rect.size.width &gt; rect.size.height) {
      width = rect.size.height;
  } else {
      width = rect.size.width;
  }
  
  double r = width / 2.0;
  float flip = -1.0;
  
  double theta = 2.0 * M_PI * (2.0 / 5.0); // 144 degrees
  
  CGContextMoveToPoint(context, xCenter, r*flip+yCenter);
  
  for (NSUInteger k=1; k&lt;5; k++)
  {
      float x = r * sin(k * theta);
      float y = r * cos(k * theta);
      CGContextAddLineToPoint(context, x+xCenter, y*flip+yCenter);
  }
  
  CGContextSetStrokeColorWithColor(context, self.color.CGColor);
  
  CGContextClosePath(context);
  CGContextStrokePath(context);
  
  }
  </code></pre>
  
  <p>I want to have just borders of star removing other inner lines is there any way to achieve that? (apart from using moveToPoint and addLine methods)</p>