title: Using CGContext, how to draw a line which starts with an unpainted dash segment?
body: <p>Using CGContext, drawing a dashed line starting with a painted segment is easy:</p>
  
  <pre><code>using (var ctx = UIGraphics.GetCurrentContext())
  {
      ctx.BeginPath();
      //... draw a path here
      var pattern = new float[] { 2, 2 };
      ctx.SetLineDash(0, pattern);
      ctx.DrawPath(CGPathDrawingMode.Stroke);
  }
  </code></pre>
  
  <p>This draws a line looking like this "xx--xx--xx--xx--", where "x" means painted, and "-" means not painted.</p>
  
  <p>Now I want to draw a line starting with an unpainted segment, that is: "--xx--xx--xx--xx". Is there an elegant way to achieve this? E.g. by telling iOS to start with an unpainted segment?</p>
  
  <p>Given our example, a line starting with unpainted segments can be achieved using the phase parameter:</p>
  
  <pre><code>using (var ctx = UIGraphics.GetCurrentContext())
  {
      ctx.BeginPath();
      //... draw a path here
      var pattern = new float[] { 2, 2 };
      ctx.SetLineDash(2, pattern);
      ctx.DrawPath(CGPathDrawingMode.Stroke);
  }
  </code></pre>
  
  <p>However, for more complex patterns (something like <code>{ 2, 4, 3, 7, 5, 6 }</code>) using the phase parameter becomes more cumbersome. The pattern probably needs to be shifted in addition to the phase parameter.</p>
  
  <p>To wrap up: Is it possible to elegantly create a line dash starting with an unpainted segment, without using the phase parameter?</p>
  
  <p>Note: The code examples are written in C# (MonoTouch), but the question applies to native iOS code as well.</p>