如何将 UIImageView 旋转 20 度?

How can I rotate an UIImageView by 20 degrees?(如何将 UIImageView 旋转 20 度?)

本文介绍了如何将 UIImageView 旋转 20 度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

What do I have to do, if I need to rotate a UIImageView? I have a UIImage which I want to rotate by 20 degrees.

The Apple docs talk about a transformation matrix, but that sounds difficult. Are there any helpful methods or functions to achieve that?

解决方案

A transformation matrix is not incredibly difficult. It's quite simple, if you use the supplied functions:

imgView.transform = CGAffineTransformMakeRotation(.34906585);

(.34906585 is 20 degrees in radians)


Swift 5:

imgView.transform = CGAffineTransform(rotationAngle: .34906585)

这篇关于如何将 UIImageView 旋转 20 度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:如何将 UIImageView 旋转 20 度?

基础教程推荐