是否可以编程旋转视图180度? [英] Is it possible to programatically rotate the view by 180 degrees?

查看:149
本文介绍了是否可以编程旋转视图180度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPhone应用程式中,我想以程式化的方式将检视旋转180度。

In my iPhone App, I want to programatically rotate the view by 180 degrees.

这是可能的,如果是的话。

Is that possible, if yes how?

谢谢!

推荐答案

应该可以使用CGAffineTransform

引自这个问题,这应该可以做到:

Quote from this question, this should do the trick:

CGFloat radians = atan2f(yourView.transform.b, yourView.transform.a);
CGFloat degrees = radians * (180 / M_PI);
CGAffineTransform transform = CGAffineTransformMakeRotation((90 + degrees) * M_PI/180);
yourView.transform = transform;

这篇关于是否可以编程旋转视图180度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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