Record a simple animation effect, write it yourself, very simple, just do the recording.
Attached to a demo:
Https://github.com/hgl753951/hglTest.git
The code is as follows:
1, prepare
BOOL _isopen; * _btnarray;
2, specific code
-(void) initui{_btnarray=[[Nsmutablearray alloc]init]; for(intI=0; i<4; i++) {UIButton* BTN =[UIButton Buttonwithtype:uibuttontypecustom]; Btn.tag=i; Btn.frame= CGRectMake (260,420, +, +); [Btn setbackgroundimage:[uiimage imagenamed:[nsstring stringWithFormat:@"c_setting%d", (i+1)%4] ] [forstate:uicontrolstatenormal]; [Btn addtarget:self Action: @selector (Btnclick:) forcontrolevents:uicontroleventtouchupinside]; [Self.view ADDSUBVIEW:BTN]; [_btnarray ADDOBJECT:BTN]; }}-(void) Btnclick: (UIButton *) btn{//if it is not open if(!_isopen) { //Open Nine grid for(inti =0; i < _btnarray.count; i++) {UIButton* Mybtn =[_btnarray objectatindex:i]; [UIView animatewithduration:0.3Animations:^{mybtn.frame= CGRectMake ( the+ (i%2)* -, -+ -* (i/2), +, +); } Completion:^(BOOL finished) {[UIView animatewithduration:0.3Animations:^{mybtn.frame= CGRectMake ( $+ (i%2)* -, the+ (i/2)* -, +, +); }]; }]; } } Else { //Close Nine grid for(inti =0; i < _btnarray.count; i++) {UIButton* Mybtn =[_btnarray objectatindex:i]; [UIView animatewithduration:0.3Animations:^{mybtn.frame= CGRectMake ( the+ (i%2)* -, -+ -* (i/2), +, +); } Completion:^(BOOL finished) {[UIView animatewithduration:0.3Animations:^{mybtn.frame= CGRectMake (260,420, +, +); }]; }]; }} _isopen= !_isopen;}
The effect is as follows:
iOS development--Adding simple animation effects