ios - How to move objects on screen? -
i have multiple lines. want hold 1 line finger , drag around screen. how can possibly using long press?
override func touchesbegan(_ touches: set<uitouch>, event: uievent?) { if let touch = touches.first { let currentpoint = touch.location(in: self.view) drawline(frompoint: currentpoint, topoint: currentpoint) } } func drawline(frompoint: cgpoint, topoint: cgpoint) { uigraphicsbeginimagecontext(self.view.frame.size) imageview.image?.draw(in: cgrect(x: 0, y: 0, width: self.view.frame.width, height: self.view.frame.height)) let context = uigraphicsgetcurrentcontext() let linewidth : cgfloat = 5 context?.move(to: cgpoint(x: frompoint.x, y: frompoint.y)) context?.addline(to: cgpoint(x: frompoint.x + 200, y: frompoint.y)) context?.setblendmode(cgblendmode.normal) context?.setlinecap(cglinecap.round) context?.setlinewidth(linewidth) context?.setstrokecolor(uicolor(red: 0, green: 0, blue: 0, alpha: 1.0).cgcolor) context?.strokepath() imageview.image = uigraphicsgetimagefromcurrentimagecontext() uigraphicsendimagecontext() }
for example, hold line 2 , want drag it. how can that?
Comments
Post a Comment