objective c - Create shake animation for UIImageView that is possible to start and stop -
i need shake uiimageview when event occurs, use following code shake animation:
cabasicanimation *shake = [cabasicanimation animationwithkeypath:@"position"]; [shake setduration:0.1]; [shake setrepeatcount:infinity]; [shake setautoreverses:yes]; [shake setfromvalue:[nsvalue valuewithcgpoint: cgpointmake(_clockimg.center.x - 5,_clockimg.center.y)]]; [shake settovalue:[nsvalue valuewithcgpoint: cgpointmake(_clockimg.center.x + 5, _clockimg.center.y)]]; [_clockimg.layer addanimation:shake forkey:@"position"];
the problem can't stop animation when want to, tried [_clockimg stopanimating];
, changing [shake setrepeatcount:0];
animation keeps going. there way stop cabasicanimation want to?
have tried:
[image.layer removeallanimations]
Comments
Post a Comment