小编Vin*_*nga的帖子

CGAffineTransformMakeRotation拉伸了我的形象,我做错了什么?

我有一张图片,显示地图上哪条路是北方.如果找到新标题,则此图像由CoreLocation更新.它也放在正确的位置,我使用以下代码:

locateMeView.transform = CGAffineTransformMakeRotation(([CoreLocationController sharedInstance].heading - 45) * M_PI / 180);
CGRect frame = locateMeView.frame;
CGPoint pos = [MapClass vectorForLocation:[CoreLocationController sharedInstance].location mapCenter:curLocation zoom:curZoom];
frame.origin.x = (int)(self.view.bounds.size.width/2 + pos.x - frame.size.width / 2);
frame.origin.y = (int)(self.view.bounds.size.height/2 + pos.y - frame.size.height / 2);
frame.size.width = 24;
frame.size.height = 24;
locateMeView.frame = frame;
Run Code Online (Sandbox Code Playgroud)

CoreLocationController是一个存储正常CoreLocation更新的类.MapClass将lat/lng坐标转换为地图上的x/y坐标.图像的位置是正确的,但旋转会产生奇怪的效果.对于0 en M_PI,图像是正确的,但在这些图像之间,图像被拉伸,好像它也围绕z轴旋转,并且在M_PI/2和3*M_PI/2处,它完全消失.有人可以解释发生了什么,我做错了什么?

iphone transform objective-c

8
推荐指数
2
解决办法
4189
查看次数

标签 统计

iphone ×1

objective-c ×1

transform ×1