如何在iPhone中同时对图像使用旋转和平移? [英] How to use Rotation and Translation for an Image simultaneously in iPhone?

查看:67
本文介绍了如何在iPhone中同时对图像使用旋转和平移?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用CGAffineTransformMakeRotation旋转图像,并使用CGAffineTransformMakeTranslation转换图像.这是我的代码:

I using CGAffineTransformMakeRotation for the Rotation of an Image and CGAffineTransformMakeTranslation for the Translation of an Image. This is my code:

-(void)rotateTranslate
{
    r++;
    CGAffineTransform transform = CGAffineTransformMakeRotation(r);
    imageView.transform = transform;
    x++;
    y++;
    CGAffineTransform transform1=CGAffineTransformMakeTranslation(x,y);
    imageView.transform= transform1;
    [self performSelector:@selector(rotateTranslate) withObject:self afterDelay:0.2];
}

我的问题是图像仅在平移而不旋转.如果我分别使用旋转"和平移",则表示效果很好.如何修改我的代码以使其正常工作?

My Problem is the Image is only Translating it is not Rotating. If I use the Rotate and Translate separately means it works Pretty well. How can I modify my code to work both well?

推荐答案

问题是您要进行单个旋转,然后平移并进行设置.因此,旋转将被平移覆盖.您必须执行类似的操作

The problem is that you are making an individual rotation and then translation and setting it. So the rotation is overridden by the translation. You must do something like this,

CGAffineTransform transform = CGAffineTransformRotate(imageView.transform, 1);
transform = CGAffineTransformTranslate(transform, 1, 1);

imageView.transform= transform;

[self performSelector:@selector(rotateTranslate) withObject:self afterDelay:0.2];

但这不会使旋转动画.它将从当前变换跳到结束变换.

But this will not animate the rotation. It will just jump from the current transform to the end transform.

而且您似乎没有定义终点.

And you don't seem to have an end point defined.

这篇关于如何在iPhone中同时对图像使用旋转和平移?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆