How to let a view rotate forever?

前端 未结 3 1261
执念已碎
执念已碎 2021-01-13 06:49

Is there a way to let a view rotate forever, with an specified speed? I need that for an indicator kind of thing. I know there is this weird Lxxxxx00ff constant (don\'t reme

3条回答
  •  再見小時候
    2021-01-13 07:34

    my bet is:

    -(void)animationDidStopSelector:... {
      [UIView beginAnimations:nil context:NULL];
      // you can change next 2 settings to setAnimationRepeatCount and set it to CGFLOAT_MAX
      [UIView setAnimationDelegate:self];
      [UIView setAnimationDidStopSelector:@selector(animationDidStopSelector:...)];
      [UIView setAnimationDuration:...
    
      [view setTransform: CGAffineTransformRotate(CGAffineTransformIdentity, 6.28318531)];
    
      [UIView commitAnimations];
    }
    
    //start rotation
    [self animationDidStopSelector:...];
    

    ok better bet:

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationRepeatCount: CGFLOAT_MAX];
    [UIView setAnimationDuration:2.0f];
    
    [view setTransform: CGAffineTransformMakeRotation(6.28318531)];
    
    [UIView commitAnimations];
    

提交回复
热议问题