給控制元件新增動畫效果
阿新 • • 發佈:2019-02-08
首先要在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"];