将UIImage或UIView旋转到特定角度,而不是角度 [英] Rotate a UIImage or UIView to a particular angle, NOT an amount of angle

查看:88
本文介绍了将UIImage或UIView旋转到特定角度,而不是角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

适用于iOS的Objective-C。

Objective-C for iOS.

如何将图像或视图旋转到特定角度。
我已经尝试过以下两种方法,但两者都旋转角度的AMOUNT,而不是角度。
基本上我想调用一个方法旋转到90',然后再次调用180',图像/视图完成180',而不是两者都添加(270')这是什么如果我使用以下任一方法,就会发生。

How do I rotate an image or view TO a particular angle. I have tried the two methods below, but both rotate the AMOUNT of angle, not TO the angle. Basically I would like to call a method to rotate to 90' and then say call again of 180', and the image/view to finish at 180', NOT an addition of them both (270') which is what happens if I use either of the methods below.

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

myImage.transform = CGAffineTransformMakeRotation(degreesToRadians(90));

myImage.transform = CGAffineTransformRotate(myImage.transform, degreesToRadians(90));

非常感谢!

推荐答案

重置

.transform = CGAffineTransformIdentity

在其他转换之前......

before the other transforms...

这篇关于将UIImage或UIView旋转到特定角度,而不是角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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