gpt4 book ai didi

ios - 旋转(固定端)带有两个角度之间动画的 imageView

转载 作者:行者123 更新时间:2023-11-29 13:22:08 25 4
gpt4 key购买 nike

您好,我正在开发一个应用程序,它需要两个角度之间的图像动画。即从 0-90 度,然后在图像达到 0 度后从 90-0 度,动画必须停止。

我正在使用以下代码,它仅提供 0-90 的动画,但我还需要使用 90 的动画将图像设置为 0。

               [UIView animateWithDuration: 0.5f
delay: 0.0f
options: options
animations: ^{
self.imageToMove.transform = CGAffineTransformRotate(imageToMove.transform, M_PI / 2);
}
completion: ^(BOOL finished) {
if (finished) {
// if flag still set, keep spinning with constant speed
[self spinWithOptions: UIViewAnimationOptionCurveLinear];
}
}
}];

请帮忙....

最佳答案

通过更改“RADIANS”的值来试试这个

    #define RADIANS(degrees) ((degrees * M_PI) / 180.0)

//- (void)startWobble

-(IBAction)start:(id)sender

{

itemView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-1));

[UIView animateWithDuration:0.15 delay:0.0 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)

animations:^ {

itemView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(1));

}

completion:NULL

];

}

//- (void)stopWobble

-(IBAction)end:(id)sender

{

[UIView animateWithDuration:0.25

delay:0.0

options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)

animations:^ {

itemView.transform = CGAffineTransformIdentity;

}

completion:NULL

];

}

关于ios - 旋转(固定端)带有两个角度之间动画的 imageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14118599/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com