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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -