国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

圖層的一些基本動畫效果

2019-11-14 18:42:46
字體:
來源:轉載
供稿:網友

#define kRadianToDegrees (radian) (radian * 180.0) / (M_PI)

//閃爍

[self.testView.layer addAnimation:[self opacityForever_Animation:0.5] forKey:nil];

//移動

[self.testView.layer addAnimation:[self duration:3 move:[NSNumber numberWithInteger:200]] forKey:nil];

//縮放

[self.testView.layer addAnimation:[self scale:[NSNumber numberWithInteger:1] orgin:[NSNumber numberWithInteger:3] durTimes:1 Rep:MAXFLOAT] forKey:nil] ;

//組合

NSArray *myArray = [NSArray arrayWithObjects:[self opacityForever_Animation:0.5], [self duration:1.0f move:[NSNumber numberWithFloat:200.0f]], [self scale:[NSNumber numberWithFloat:1.0f] orgin:[NSNumber numberWithFloat:3.0f] durTimes:2.0f Rep:MAXFLOAT], nil];

 [self.testView.layer addAnimation:[self groupAnimation:myArray durTimes:3.0f Rep:MAXFLOAT] forKey:nil];

//路徑

CGMutablePathRef myPah = CGPathCreateMutable();

CGPathMoveToPoint(myPah, nil,30, 77);

CGPathAddCurveToPoint(myPah, nil, 50, 50, 60, 200, 200, 200);//這里的是控制點。

[self.testView.layer addAnimation:[self keyframeAnimation:myPah durTimes:5 Rep:MAXFLOAT] forKey:nil];

//旋轉

[self.testView.layer addAnimation:[self rotation:2 degree:kRadianToDegrees(90) direction:1 repeatCount:MAXFLOAT] forKey:nil];

//移除

[self.testView.layer removeAllAnimations];

 

 

#PRagma mark === 閃爍 ======

- (CABasicAnimation *)opacityForever_Animation:(float)time

{

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];//必須寫opacity才行。

    animation.fromValue = [NSNumber numberWithFloat:1.0f];

    animation.toValue = [NSNumber numberWithFloat:0.0f];//這是透明度。

    animation.autoreverses = YES;

    animation.duration = time;

    animation.repeatCount = MAXFLOAT;

    animation.removedOnCompletion = NO;

    animation.fillMode = kCAFillModeForwards;

    animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];///沒有的話是均勻的動畫。

    return animation;

}

 

#pragma mark =====橫向、縱向移動===========

-(CABasicAnimation *)duration:(float)time move:(NSNumber *)x

{

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.translation.x"];///.y的話就向下移動。

    animation.toValue = x;

    animation.duration = time;

    animation.removedOnCompletion = NO;//yes的話,又返回原位置了。

    animation.repeatCount = MAXFLOAT;

    animation.fillMode = kCAFillModeForwards;

    return animation;

}

 

#pragma mark =====縮放-=============

-(CABasicAnimation *)scale:(NSNumber *)Multiple orgin:(NSNumber *)orginMultiple durTimes:(float)time Rep:(float)repertTimes

{

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

    animation.fromValue = Multiple;

    animation.toValue = orginMultiple;

    animation.autoreverses = YES;

    animation.repeatCount = repertTimes;

    animation.duration = time;//不設置時候的話,有一個默認的縮放時間.

    animation.removedOnCompletion = NO;

    animation.fillMode = kCAFillModeForwards;

    return  animation;

}

 

#pragma mark =====組合動畫-=============

-(CAAnimationGroup *)groupAnimation:(NSArray *)animationAry durTimes:(float)time Rep:(float)repeatTimes

{

    CAAnimationGroup *animation = [CAAnimationGroup animation];

    animation.animations = animationAry;

    animation.duration = time;

    animation.removedOnCompletion = NO;

    animation.repeatCount = repeatTimes;

    animation.fillMode = kCAFillModeForwards;

    return animation;

}

 

#pragma mark =====路徑動畫-=============

-(CAKeyframeAnimation *)keyframeAnimation:(CGMutablePathRef)path durTimes:(float)time Rep:(float)repeatTimes

{

    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

    animation.path = path;

    animation.removedOnCompletion = NO;

    animation.fillMode = kCAFillModeForwards;

    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

    animation.autoreverses = NO;

    animation.duration = time;

    animation.repeatCount = repeatTimes;

    return animation;

}

 

#pragma mark ====旋轉動畫======

-(CABasicAnimation *)rotation:(float)dur degree:(float)degree direction:(int)direction repeatCount:(int)repeatCount

{

    CATransform3D rotationTransform = CATransform3DMakeRotation(degree, 0, 0, direction);

    CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform"];

    animation.toValue = [NSValue valueWithCATransform3D:rotationTransform];

    animation.duration  =  dur;

    animation.autoreverses = NO;

    animation.cumulative = NO;

    animation.fillMode = kCAFillModeForwards;

    animation.repeatCount = repeatCount;

    animation.delegate = self;

    return animation;

}

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 台东市| 富锦市| 来宾市| 澜沧| 大余县| 潜山县| 勃利县| 江北区| 依兰县| 昌都县| 凤庆县| 乌兰察布市| 太保市| 怀集县| 易门县| 辰溪县| 登封市| 孝感市| 江津市| 菏泽市| 军事| 大田县| 仙居县| 赤峰市| 花莲县| 万山特区| 新蔡县| 盐津县| 潞西市| 环江| 临海市| 安庆市| 射阳县| 新乡市| 泰宁县| 隆德县| 灵台县| 当涂县| 蓬莱市| 晴隆县| 晴隆县|