如何在iOS上以编程方式将视图旋转180度? [英] How to programmatically rotate the view by 180 degrees on iOS?
本文介绍了如何在iOS上以编程方式将视图旋转180度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在iPhone App中以编程方式将视图旋转180度?
How to programmatically rotate the view by 180 degrees in my iPhone App?
推荐答案
应该可以通过使用 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;
这篇关于如何在iOS上以编程方式将视图旋转180度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文