repeatCount和repeatDuration

来源:互联网 发布:win10win7共享网络 编辑:程序博客网 时间:2024/06/03 23:00

1. repeatCount

    _layer = [CALayerlayer];

    [_layersetFrame:CGRectMake(300,50, 100,200)];

    [_layersetBackgroundColor:[UIColorredColor].CGColor];

    [self.view.layeraddSublayer:_layer];

    CABasicAnimation *animation = [CABasicAnimationanimationWithKeyPath:@"transform.rotation"];

    [animation setDuration:2];

    [animation setRepeatCount:3.5];

    [animation setToValue:@(M_PI_2)];

    [_layeraddAnimation:animation forKey:@"rotationAnimation"];


2.

     _layer = [CALayerlayer];

    [_layersetFrame:CGRectMake(300,50, 100,200)];

    [_layersetAnchorPoint:CGPointMake(1,0.5)]; //锚点x等于1表示绕右侧的轴旋转; 0 表示绕左侧的轴旋转

    [_layersetBackgroundColor:[UIColorredColor].CGColor];

    [self.view.layeraddSublayer:_layer];


    CATransform3D perspective =CATransform3DIdentity;

    perspective.m34 = -1.0 /500.0;

    self.view.layer.sublayerTransform = perspective;


    CABasicAnimation *animation = [CABasicAnimationanimation];

    animation.keyPath =@"transform.rotation.y";

    animation.toValue =@(M_PI_4);

    [animation setRepeatDuration:2];

    [animation setAutoreverses:YES];

    [_layeraddAnimation:animation forKey:nil];





0 0
原创粉丝点击