ios给控件添加动画效果

首先要在framework中引入QuatrtzCore.framework,在头文件中需要

#import <QuartzCore/QuartzCore.h>

CATransition *animation = [CATransition animation];

    [animation setDuration:1.25f]; 

    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]]; 

    [animation setType:@"cube"];

    [animation setSubtype: kCATransitionFromBottom];

    CGRect rect = [text frame];

    CGRect rect1=[btn frame];

    

    [btn setFrame:rect1];

    [text setFrame:rect];

    if([text isHidden]){

        [text setHidden:NO];

    }else{

        [text setHidden:YES]; 

    }

    

    [UIView commitAnimations];

    [text.layer addAnimation:animation forKey:@"Reveal"];

你可能感兴趣的:(ios)