graphics - How do I create an onClick drawLine function in swift? -
i need create function make line connecting 2 buttons when pressed. however, way can figure out how create line predetermined start , endpoint.
func drawlinefrom(frompoint: cgpoint, topoint: cgpoint) { uigraphicsbeginimagecontext(view.frame.size) let context = uigraphicsgetcurrentcontext() cgcontextsetlinewidth(context, 3.0) /* setting line width: set let , width next (let, width) */ cgcontextsetstrokecolorwithcolor(context, uicolor.purplecolor().cgcolor) cgcontextmovetopoint(context, oldlocation.x, oldlocation.y) cgcontextaddlinetopoint(context, newlocation.x, newlocation.y) cgcontextstrokepath(context) uigraphicsendimagecontext() }
when call function, in class, testing, have figured out entire thing runs, , oldlocation , newlocation have appropriate values create line. however, no line created (or @ least not visible). there command neglecting run, or else problem?
Comments
Post a Comment