One
Call
| 123456 |
if (M_viewscenario.superview = = nil ) <br>{ &NBSP;&NBSP;&NBSP;&NBSP; m_viewscenario.alpha = 1.0; &NBSP;&NBSP;&NBSP;&NBSP; m_viewscenario.transform = cgaffinetransformidentity; &NBSP;&NBSP;&NBSP;&NBSP; [ self zoomin:m _viewscenario andanimationduration:1.0 andwait: yes &NBSP;&NBSP;&NBSP;&NBSP; [ self .view Addsubview:m_viewscenario]; |
Show, from small to big
| 12345678910111213 |
- (void)zoomIn: (UIView *)view andAnimationDuration: (float) duration andWait:(BOOL) wait{ __block BOOLdone = wait; view.transform = CGAffineTransformMakeScale(0, 0); [UIView animateWithDuration:duration animations:^{ view.transform = CGAffineTransformIdentity; } completion:^(BOOLfinished) { done = NO; }]; while(done == YES) [[NSRunLoopcurrentRunLoop] runUntilDate:[NSDatedateWithTimeIntervalSinceNow:0.01]];} |
There are big changes to small calls
| 12 |
[selfzoomOut:m_viewScenario andAnimationDuration:1.0 andWait:NO];[selfremoveScenarioView]; |
Big variable small function
| 1234567891011 |
- (void)zoomOut: (UIView *)view andAnimationDuration: (float) duration andWait:(BOOL) wait{ __block BOOLdone = wait; view.transform = CGAffineTransformIdentity; [UIView animateWithDuration:duration animations:^{ view.transform = CGAffineTransformMakeScale(0, 0); } completion:^(BOOLfinished) { done = YES; }]; while(done == NO) [[NSRunLoop currentRunLoop] runUntilDate:[NSDatedateWithTimeIntervalSinceNow:0.01]];} |
Two, if you need an animation like Uialertview
Show Call
| 12345678 |
if < code> nil ) { m_viewscenario.alpha = 1.0; &NBSP;&NBSP;&NBSP;&NBSP; m_viewscenario.transform = cgaffinetransformidentity; &NBSP;&NBSP;&NBSP;&NBSP; [ self .view Addsubview:m_viewscenario]; &NBSP;&NBSP;&NBSP;&NBSP; [ self zoomin:m_viewscenario andanimationduration:1.0]; |
Small Change Big animation
| 1234567891011121314151617 |
- (void)zoomIn: (UIView *)view andAnimationDuration: (float) duration{ CAKeyframeAnimation * animation; animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"]; animation.duration = duration; //animation.delegate = self; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; NSMutableArray*values = [NSMutableArrayarray]; [values addObject:[NSValuevalueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]]; [values addObject:[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]]; [values addObject:[NSValuevalueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]]; [values addObject:[NSValuevalueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]]; animation.values = values; animation.timingFunction = [CAMediaTimingFunction functionWithName: @"easeInEaseOut"]; [view.layer addAnimation:animation forKey:nil];} |
Big to small, call ditto, function changes slightly
| 123456789101112 |
- (void)zoomOut: (UIView *)view andAnimationDuration: (float) duration andWait:(BOOL) wait{ __block BOOLdone = wait; view.transform = CGAffineTransformIdentity; [UIView animateWithDuration:duration animations:^{ view.transform = CGAffineTransformMakeScale(0, 0); view.alpha = 0.0; } completion:^(BOOLfinished) { done = YES; }]; while(done == NO) [[NSRunLoopcurrentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:0.01]]; |
iOS UIView common animation effects