The micro-letter shaking animation effect looks great, here is a similar shake animation effect, code example:
The code is as follows |
Copy Code |
#pragma mark-Shake it. -(void) Motionbegan: (uieventsubtype) Motion withevent: (uievent *) event { if (motion = = Uieventsubtypemotionshake) { Audioservicesplaysystemsound (ksystemsoundid_vibrate); Vibration effect [Self shakeview:phoneimgview]; The Phoneimgview here is a picture control that needs shaking effect. } } #pragma mark-Animation -(void) Shakeview: (uiview*) Viewtoshake { CGFloat t = 14.0; Cgaffinetransform translateright = cgaffinetransformtranslate (cgaffinetransformidentity, T, 0.0); Cgaffinetransform translateleft = cgaffinetransformtranslate (cgaffinetransformidentity, T, 0.0); Viewtoshake.transform = Translateleft;
[UIView animatewithduration:0.08 delay:0.0 options:uiviewanimationoptionautoreverse| Uiviewanimationoptionrepeat animations:^{ [UIView setanimationrepeatcount:5.0]; Viewtoshake.transform = Translateright; } completion:^ (BOOL finished) { if (finished) { [UIView animatewithduration:0.08 delay:0.0 options:uiviewanimationoptionbeginfromcurrentstate animations:^{ Viewtoshake.transform =cgaffinetransformidentity; } Completion:null]; } }]; } |
Note: the need for vibration effect, to import audiotoolbox.framework, and then import the header file "Audiotoolbox/audiotoolbox.h", the realization of the shaking animation effect looks good, you can try in their own projects.