Objective c 如何(如果可能)设置CGAffineTransformRotate的持续时间

Objective c 如何(如果可能)设置CGAffineTransformRotate的持续时间,objective-c,ios,Objective C,Ios,我的代码中有一个标准的CGAffineTransformRotate旋转CALayer。我还无法确定如何设置动画的持续时间 有什么想法吗 谢谢大卫,多亏了你的评论,我才找到了我需要的东西。有时候我觉得你需要一个全新的视角,在盯着屏幕看了8个小时之后,干杯 杰克 此代码可能会对您有所帮助 // if you dont use this code with a UIButton cange the UIButton befor the "animateWithDuration:" - (IBAct

我的代码中有一个标准的CGAffineTransformRotate旋转CALayer。我还无法确定如何设置动画的持续时间

有什么想法吗

谢谢大卫,多亏了你的评论,我才找到了我需要的东西。有时候我觉得你需要一个全新的视角,在盯着屏幕看了8个小时之后,干杯

杰克

此代码可能会对您有所帮助

// if you dont use this code with a UIButton cange the UIButton befor the "animateWithDuration:"

- (IBAction)rotate:(id)sender {

        [UIButton animateWithDuration:1.0 /* <---- duration of the animation (float)*/

                           animations:^{   /*block for animation*/

                               CGAffineTransform rotate = CGAffineTransformMakeRotation( 360 /* <---- Rotation degrees*/ / 180.0 * M_PI );
                               [button setTransform:rotate];

                             }
                         completion:^(BOOL finished){ /*code block triggerd when animation is done*/ }];

        // if here is an NSLog it wil probably be triggerd befor the animation ends

    }
//如果不将此代码与UIButton一起使用,请在“animateWithDuration:”之前使用UIButton
-(iAction)旋转:(id)发送器{

[UIButton animateWithDuration:1.0/*与您为其他所有内容指定动画持续时间的方式相同?如何设置动画?隐式?如果是,请更改为显式动画,以便您可以指定持续时间。请确保发布您的答案并将其标记为正确(一旦您能够这样做)。