How to draw a line on top of an image when finger moves on iPhone -


i trying draw line on top of background image in uiview tracing movements of user's finger. can accomplish drawing uiimage background , doing line drawing in drawrect have load image each time drawrect called , makes performance sluggish. alternatively, if use uiimageview background image (just adding view in ib or programatically) lines disappear when dragged on image. there way tell lines draw on top of uiimageview. help.

here code using uiimage method:

- (void)drawrect:(cgrect)rect {     uiimage *imagefield = [uiimage imagenamed:@"field.jpg"];     cgrect rectforimage=cgrectmake(0,0,200,200);     [imagefield drawinrect:rectforimage];          cgcontextref context = uigraphicsgetcurrentcontext();         cgcontextmovetopoint(context, x1, y1);     cgcontextaddlinetopoint(context, x2, y2);     cgcontextstrokepath(context); } 

adding image background view correct way it. problem lies in fact added image directly view. subviews displayed on top of view, not behind it. correctly use container view holds image view background, , line-drawing view on top of that.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -