gpt4 book ai didi

ios - UIImageView 重新调整大小并同时旋转 UIImageView?

转载 作者:行者123 更新时间:2023-12-01 16:37:01 26 4
gpt4 key购买 nike

我的 UIViewController 中有一个 UIImageView。我在上面设置了一个图像。我做了如下旋转。

- (void) runSpinAnimationOnView:(UIImageView*)view duration:(CGFloat)duration rotations:(CGFloat)rotations repeat:(float)repeat
{
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 /* full rotation*/ * rotations * duration ];
rotationAnimation.duration = duration;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = repeat;

[view.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];

}

我称之为
[self runSpinAnimationOnView:_imageView duration:1.0 rotations:360 repeat:1.0];

现在我也想调整相同的 ImageView 的大小,但从各个方面都具有相同的比例,我该怎么做。

简单地说,我想旋转 UIImageView 并同时调整它的大小。

谢谢

最佳答案

CGAffineTransformConcat 将达到您的目的,它将两个变换合二为一并制作为单个动画。试试这个。

[UIView animateWithDuration: 3.0f
delay: 0
options: (UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction)
animations:^{

UIView *yourViewToBeAnimated = YourViewToBeSetHere;

CGAffineTransform animationToRotate = CGAffineTransformMakeRotation(45);

CGAffineTransform animationToScale = CGAffineTransformMakeScale(2, 2);//Double the size


yourViewToBeAnimated.transform = CGAffineTransformConcat(animationToScale, animationToRotate);


}
completion:^(BOOL finished) {




}
];

关于ios - UIImageView 重新调整大小并同时旋转 UIImageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27313702/

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