ios - How to draw a dashed line using CGContext / CGContextRef? Why is my code producing a solid line? -


this xamarin.ios code presume native folks can spot problem too, tagged objc.

i'm subclassing uiview , "abuse" draw dashed line view's x, y view's right, bottom bounds.

the color set white. line style supposed dashed. black, solid line. doing wrong here?

public override void draw (rectanglef rect) {     using (cgcontext g = uigraphics.getcurrentcontext ())     {         g.setlinewidth (1f);     g.setlinedash (0, new float[] { 10f, 4f });          g.moveto (rect.x, rect.y);         g.addlinetopoint (rect.right, rect.bottom);         g.setstrokecolor (this.color.cgcolor);         g.strokepath ();     } } 

as answer becomes obvious once post question here :-)

this line causing problem:

g.setlinedash (0, new float[] { 10f, 4f }); 

it has be:

g.setlinedash (0, new float[] { 10f, 4f }, 2); 

from apple's documentation:

if lengths parameter specifies array, pass number of elements in array. otherwise, pass 0.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -