同时平移、旋转和重新定义 UIView 的原点

发布于 2024-12-21 22:30:54 字数 374 浏览 3 评论 0原文

我正在 UIView 中制作游戏。我正在尝试模拟启用指南针自动地图方向时 iOS 地图应用程序的工作方式。 我有一个 UIView,我正在尝试更改地图的 X 和Y 坐标、角度和中心点(原点)。 但我在思考如何去做时遇到了一些困难。 这是我正在尝试使用的: (此代码位于游戏循环内)

//move map
CGRect oldFrame = mapView.frame;
oldFrame.origin.y += 1;
mapView.frame = oldFrame;
//rotate map
mapView.transform = CGAffineTransformMakeRotation(mapAngle);

那么,有人有什么建议吗?

谢谢。

I'm making a game in UIView. I'm trying to simulate the way the iOS Maps app works, when the compass auto-map-orientation is enabled.
I have a UIView, and I'm trying to change the map's X & Y co-ordinates, its angle, and its center point (origin).
But I'm having some trouble getting my head around how to do it.
Here's what I'm trying to use:
(this code is inside a game loop)

//move map
CGRect oldFrame = mapView.frame;
oldFrame.origin.y += 1;
mapView.frame = oldFrame;
//rotate map
mapView.transform = CGAffineTransformMakeRotation(mapAngle);

So, does anyone have any suggestions?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文