iOS UIView common animation effects

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.