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

首頁 > 系統 > iOS > 正文

iOS 動畫(2)

2019-11-07 23:46:43
字體:
來源:轉載
供稿:網友

此處設置的動畫是對UIImageView的CALayer設置

    _imagelayer = [CALayer layer];    _imagelayer.cornerRadius =6;    _imagelayer.borderWidth = 1;    _imagelayer.borderColor =[UIColor blueColor].CGColor;    _imagelayer.masksToBounds = YES;    _imagelayer.frame = CGRectMake(30, 30, 100, 115);    _imagelayer.contents = (id)[[UIImage imageNamed:@"icon_baiban"]CGImage];    [self.view.layer addSublayer:_imagelayer];

下面是動畫方法

//位移-(void)move{    CGPoint fromPoint = _imagelayer.position;    CGPoint toPoint = CGPointMake(fromPoint.x +80, fromPoint.y);    CABasicAnimation *anim =[CABasicAnimation animationWithKeyPath:@"pasition"];    anim.fromValue =[NSValue valueWithCGPoint:fromPoint];    anim.toValue = [NSValue valueWithCGPoint:toPoint];    anim.duration = 0.5;    _imagelayer.position = toPoint;    anim.removedOnCompletion = YES;    [_imagelayer addAnimation:anim forKey:nil];}//旋轉-(void)rotate{     CABasicAnimation *anim =[CABasicAnimation animationWithKeyPath:@"transform"];    CATransform3D fromeValue = _imagelayer.transform;    anim.fromValue = [NSValue valueWithCATransform3D:fromeValue];    CATransform3D toValue = CATransform3DRotate(fromeValue,  M_PI, 1, 0, 0);    anim.toValue = [NSValue valueWithCATransform3D:toValue];    anim.duration = 0.5;    _imagelayer.transform = toValue;    anim.removedOnCompletion = YES;    [_imagelayer addAnimation:anim forKey:nil];}//縮放-(void)scale{    CAKeyframeAnimation *anim =[CAKeyframeAnimation animationWithKeyPath:@"transform"];    anim.values =[NSArray arrayWithObjects:[NSValue valueWithCATransform3D:_imagelayer.transform],[NSValue     valueWithCATransform3D:CATransform3DScale(_imagelayer.transform, 0.2, 0.2, 1)],[NSValue  valueWithCATransform3D:CATransform3DScale(_imagelayer.transform, 2, 2, 1)],[NSValue valueWithCATransform3D:_imagelayer.transform], nil];    anim.duration =5;    anim.removedOnCompletion = YES;    [_imagelayer addAnimation:anim forKey:nil];}//動畫組-(void)group{    CGPoint fromPoint = _imagelayer.position;    CGPoint toPoint =CGPointMake(280, fromPoint.y + 200);    CABasicAnimation *moveAnim =[CABasicAnimation animationWithKeyPath:@"position"];    moveAnim.fromValue =[NSValue valueWithCGPoint:fromPoint];    moveAnim.toValue =[NSValue valueWithCGPoint:toPoint];    moveAnim.removedOnCompletion = YES;    CABasicAnimation *transform =[CABasicAnimation animationWithKeyPath:@"transform"];    CATransform3D fromeValue =_imagelayer.transform;    transform.fromValue =[NSValue valueWithCATransform3D:fromeValue];    CATransform3D scaleValue = CATransform3DScale(fromeValue, 0.5, 0.5, 1);        CATransform3D rotateValue = CATransform3DRotate(fromeValue, M_PI, 0, 0, 1);    CATransform3D tovalue =CATransform3DConcat(scaleValue, rotateValue);    transform.toValue =[NSValue valueWithCATransform3D:tovalue];    transform.cumulative = YES;    transform.repeatCount= 2;    transform.duration = 3;    CAAnimationGroup *animGroup = [CAAnimationGroup animation];    animGroup.animations = [NSArray arrayWithObjects:moveAnim,transform, nil];    animGroup.duration =6;    [_imagelayer addAnimation:animGroup forKey:nil];}


上一篇:iOS 動畫(3)

下一篇:iOS 動畫(1)

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泊头市| 共和县| 南京市| 石阡县| 兴宁市| 都江堰市| 水富县| 临夏市| 宽甸| 泰宁县| 周至县| 全南县| 绍兴市| 昭通市| 南汇区| 伊通| 揭阳市| 丹巴县| 连州市| 敦化市| 邯郸县| 内黄县| 棋牌| 仪征市| 西吉县| 登封市| 金沙县| 美姑县| 莫力| 图木舒克市| 广水市| 横峰县| 呼和浩特市| 临清市| 广平县| 会昌县| 厦门市| 汝阳县| 金华市| 泌阳县| 桦南县|