iPhone UIImageView 旋转

标签 iphone uiimage

谁能告诉我如何以圆周运动旋转图像

最佳答案

您可以将 View 旋转一定的弧度,无论它是小于完整旋转还是完整旋转的许多倍,而不必将旋转分割成多个部分。例如,以下代码将每秒旋转一次 View 指定的秒数。您可以轻松地将其修改为将 View 旋转一定数量的旋转或一定数量的弧度。

- (void) runSpinAnimationWithDuration:(CGFloat) duration;
{
    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 = 1.0; 
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];

    [myView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

关于iPhone UIImageView 旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1421050/

相关文章:

.net - 为什么 Apple 允许在 iPhone 上使用 .NET 而不允许使用 Flash?

iphone - 如何正确更新表中部分中动态变化的行数(及其单元格内容)?

ios4 - 将之前通过手势旋转的 UIImageView 与另一个合并。 WYS 不是 WYG

ios - 如何在 Swift 上使这段代码异步

ios - 如何在 iOS 中将 PNG 图像转换为 CMYK?

iphone - iOS 配置文件错误

iphone - 无法上传图片

iphone - 如何在 Safari 中打开 UIWebview 中的链接

swift - 当 UIImagePNGRepresentation 总是返回 nil 时保存 UIImage

ios - 将 URL 图像与 UIButton 一起使用