animation

来源:互联网 发布:微波电路s参数矩阵 编辑:程序博客网 时间:2024/05/21 14:10
 

animation keyPath structure Fielddescriptiontransform.rotation.x   角度,x轴(

[NSNumber numberWithFloat:1.0];

transform.rotation.y角度,y轴()transform.rotation.z角度,z轴

transform.rotation

角度scale.x范围,x轴scale.y范围,y轴

scale.z

范围,z轴scale范围position.xx轴的位置position.yy轴的位置position.zz轴的位置position位置([NSValue valueWithCGPoint:groupLayer.position]


 //演员初始化

    CALayer* groupLayer = [[CALayeralloc]init];

    groupLayer.frame = CGRectMake(60, 340+100+kYOffset,50,50);

    groupLayer.cornerRadius = 10;

    groupLayer.backgroundColor = [UIColorcolorWithPatternImage:[UIImageimageNamed:@"heart.png"]].CGColor;

    [self.view.layeraddSublayer:groupLayer];


//设定剧本

    CABasicAnimation* moveAnimation =                  

    [CABasicAnimationanimationWithKeyPath:@"position.x"];

    moveAnimation.fromValue = [NSNumbernumberWithFloat:groupLayer.position.x];

    moveAnimation.toValue = [NSNumbernumberWithFloat:300];

    moveAnimation.autoreverses = YES;

    moveAnimation.repeatCount =MAXFLOAT;

    moveAnimation.duration = 2;


   

 /*

    CABasicAnimation* moveAnimation = [CABasicAnimation animationWithKeyPath:@"position"];

    moveAnimation.fromValue = [NSValue valueWithCGPoint:groupLayer.position];

    moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(320-80, groupLayer.position.y)];

    moveAnimation.autoreverses = YES;

    moveAnimation.repeatCount =MAXFLOAT;

    moveAnimation.duration = 2;

    [groupLayer addAnimation:moveAnimation forKey:@"scaleAnimation"];

    */




//开演


    [groupLayer addAnimation:moveAnimation forKey:@"scaleAnimation"];





0 0
原创粉丝点击