Tha*_*nks 46 iphone cocoa-touch uikit uiimageview ios
如果我需要旋转一个,我该UIImageView
怎么办?我有一个UIImage
我要旋转20度.
Apple文档谈论转换矩阵,但这听起来很难.是否有任何有用的方法或功能来实现这一目标?
ale*_*hun 106
如果要向右转,如果要向左旋转,则值必须大于0,并使用符号" - "表示值.例如-20.
CGFloat degrees = 20.0f; //the value in degrees
CGFloat radians = degrees * M_PI/180;
imageView.transform = CGAffineTransformMakeRotation(radians);
Run Code Online (Sandbox Code Playgroud)
斯威夫特4:
let degrees: CGFloat = 20.0 //the value in degrees
let radians: CGFloat = degrees * (.pi / 180)
imageView.transform = CGAffineTransform(rotationAngle: radians)
Run Code Online (Sandbox Code Playgroud)
Ed *_*rty 92
转换矩阵并不难以置信.如果你使用提供的函数,这很简单:
imgView.transform = CGAffineTransformMakeRotation(.34906585);
Run Code Online (Sandbox Code Playgroud)
(.34906585是弧度20度)
xsc*_*der 10
Swift版本:
let degrees:CGFloat = 20
myImageView.transform = CGAffineTransformMakeRotation(degrees * CGFloat(M_PI/180) )
Run Code Online (Sandbox Code Playgroud)
斯威夫特 4.0
imageView.transform = CGAffineTransform(rotationAngle: CGFloat(20.0 * Double.pi / 180))
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
42322 次 |
最近记录: |