麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

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

圖層的一些基本動畫效果

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;

}

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 农村少妇吞精夜夜爽视频 | 在线看一区二区三区 | 色综合网在线观看 | 2019天天干夜夜操 | 九九热在线视频观看 | 久久久久久久免费视频 | 777zyz色资源站在线观看 | 一级片九九 | 九九热视频免费观看 | 国产福利视频在线观看 | 蜜桃传媒视频麻豆第一区免费观看 | 亚洲午夜免费电影 | 成人毛片免费看 | 久久久精品综合 | 欧美精品网址 | 国产精品免费观看视频 | 久草在线观看资源 | 91成人精品 | 黄色网址免费在线播放 | 久久国产精品一区 | 成人444kkkk在线观看 | 中文字幕在线播放一区 | 久色porn| 羞羞视频免费观看网站 | 久久亚洲精品国产一区 | 成人性爱视频在线观看 | av中文字幕免费在线观看 | 精国产品一区二区三区 | 日韩黄a| 嗯~啊~用力~高h | 一区二区三区小视频 | 亚洲第一成人av | 黄色大片在线观看 | 精品国产看高清国产毛片 | 午夜视频久久久 | 在线高清中文字幕 | 久久久久久久91 | 国产伦久视频免费观看视频 | 一级做a爱片性色毛片 | 欧美成人免费在线视频 | 巨乳毛片 |