1.讓圖片旋轉(zhuǎn)
UIImageView *imageView = [[UIImageView alloc]init];
imageView.frame = CGRectMake(50, 50, 200, 200);
imageView.image = [UIImage imageNamed:@"460.jpg"];
CGAffineTransform transform= CGAffineTransformMakeRotation(M_PI*0.38);
imageView.transform = transform;//旋轉(zhuǎn)
/*關(guān)于M_PI
#define M_PI 3.14159265358979323846264338327950288
其實(shí)它就是圓周率的值倍奢,在這里代表弧度缀拭,相當(dāng)于角度制 0-360 度越平,M_PI=180度
旋轉(zhuǎn)方向?yàn)椋喉槙r(shí)針旋轉(zhuǎn)
2.旋轉(zhuǎn)后,獲得這個(gè)圖片旋轉(zhuǎn)的角度
CGAffineTransform _trans = imageView.transform;
CGFloat rotate = acosf(_trans.a);
// 旋轉(zhuǎn)180度后,需要處理弧度的變化
if (_trans.b < 0) {
rotate = M_PI -rotate;
}
// 將弧度轉(zhuǎn)換為角度
CGFloat degree = rotate/M_PI * 180;
---------------------
作者:技術(shù)無他
來源:CSDN
原文:https://blog.csdn.net/fengchenlangzi_/article/details/52928746
版權(quán)聲明:本文為博主原創(chuàng)文章退唠,轉(zhuǎn)載請(qǐng)附上博文鏈接箱锐!