iphone - How to connect two buttons( dots) with a line in iOS? -
this question has answer here:
- draw line between 2 points in iphone? 3 answers
i want make project in have touch 1 dot , connect dot , after connect dot. when connect 1 dot dot line create between them.
actually when click/ touch 1 dot line show , when touch second dot line create between 2 dots.
i not able yet, trying , searching on net unable find solution yet.
this need 1 https://play.google.com/store/apps/details?id=zok.android.dots&hl=en
i think done uigesture recogniser? or else? how can achieve this?
any idea or suggestions experts highly welcome.
modify code according requiements
cgcontextref context = uigraphicsgetcurrentcontext(); uicolor *currentcolor = [uicolor blackcolor]; cgcontextsetstrokecolorwithcolor(context, currentcolor.cgcolor); cgcontextsetlinewidth(context, 2.0); cgcontextbeginpath(context); cgcontextmovetopoint(context, touchstart.x, touchstart.y); cgcontextaddlinetopoint(context, touchend.x, touchend.y); cgcontextstrokepath(context);
@nisha:
make gloabal instances of cgpoint
touchstart
, touchend
, them this:
- (void)touchesbegan:(nsset *)touches withevent:(uievent *)event{ touchend = cgpointzero; touchstart = cgpointzero; uitouch *touch = [touches anyobject]; cgpoint point = [touch locationinview:self]; nslog(@"start point >> %@",nsstringfromcgpoint(point)); touchstart = point; }
}
- (void)touchesmoved:(nsset *)touches withevent:(uievent *)event { uitouch *touch = [touches anyobject]; cgpoint point = [touch locationinview:self]; touchend = point; [self setneedsdisplay]; }
Comments
Post a Comment