ios - How do I make this animation go counterclockwise? -


i have got part of animation completed. trying create line border animation this, line travels across top , right side of rectangle. need in addition creating line mirrors line shown in video (traveling across left side bottom of rectangle),counterclockwise. tried doing using -bezierpathbyreversingpath(_:) function, made origin line begin in bottom left of rectangle. not sure do, appreciated! here’s code:

// create layer rightline = cashapelayer() rightline.bounds = centerbutton.bounds rightline.position = view.center rightline.path = uibezierpath(rect: rightline.bounds).cgpath rightline.linewidth = 3 rightline.strokecolor = uicolor(hex: "3d424e").cgcolor rightline.fillcolor = uicolor.clearcolor().cgcolor rightline.strokestart = 0 rightline.strokeend = 0  // create animation let rightstart = cabasicanimation(keypath: "strokestart") rightstart.tovalue = 0 let rightend = cabasicanimation(keypath: "strokeend") rightend.tovalue = 0.5  rightlinegroup = caanimationgroup() rightlinegroup.animations = [rightstart, rightend] rightlinegroup.duration = 1.5 rightlinegroup.autoreverses = true rightlinegroup.repeatcount = huge // repeat forever  self.view.layer.addsublayer(rightline) rightline.addanimation(rightlinegroup, forkey: nil) 

animating strokestart 0 zero nothing.

you want leave strokeend @ 1.0 (the default) , animate strokestart 1.0 0.5. should have desired effect.


Comments