swift - animate different buttons to the correct location -
how can animate different buttons? make 16 buttons in loop:
for in 1..<17 { if(i == 5 || == 9 || == 13){ added = 0 movetobottom += 60 } var button = uibutton(frame: cgrectmake(cgfloat(int(middlewidth) + added), cgfloat(movetobottom), 50, 50)) self.view.addsubview(button) uiview.animatewithduration(2, animations:{ button.frame = cgrectmake(cgfloat(int(middlewidth) + added), cgfloat(int(middleheight) + movetobottom), 50, 50) },completion: nil ) }
and animate them correct place, buttons on exact same time animation. not want, buttons must animate on different times location, how can that?
do means add animation button 1 one ?
try function, , configure delay parameter.
uiview.animatewithduration(duration: nstimeinterval, delay: nstimeinterval, options: uiviewanimationoptions, animations: { () -> void in // animate code... }, completion: // completion block .... )
in condition, write instead:
uiview.animatewithduration(2, delay: 2*(i-1), options: uiviewanimationoptions.curvelinear, animations: { () -> void in button.frame = cgrectmake(cgfloat(int(middlewidth) + added), cgfloat(int(middleheight) + movetobottom), 50, 50) }, completion: nil)
Comments
Post a Comment