iPhone用代码定位UIImageView?当然解决起来很简单

发布于 2024-10-03 21:14:07 字数 155 浏览 0 评论 0原文

这很简单,所以我不确定为什么我不能这样做。当我的应用程序处于活动状态时,我想做的就是定位一些 UIImageView。我一直在使用 CGAffineTransformMakeTranslation,但现在我可以看到这是不正确的,因为它将视图移动设定的量而不是将其移动到设定的位置。我应该使用什么?

This is very simple so I'm not sure why I can't do this. All I want to do it position some UIImageViews when my app becomes active. I had been using CGAffineTransformMakeTranslation but I can now see that this is not correct because it moves the view a set amount rather than moving it to a set position. What should I be using?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

乞讨 2024-10-10 21:14:07

您可以将 UIImageView 的框架更改为:

  1. 将框架的 x 和 y 原点设置为您想要的位置
    UIImageView 相对于包含视图放置。
  2. 保持 UIImageView 的宽度和高度相同,

如下所示:

imageView.frame = CGRectMake([desired x coordinate], [desired y coordinate], imageView.frame.size.width, imageView.frame.size.height);

You could just change the frame of your UIImageView to:

  1. set the x and y origin of the frame to the position you want your
    UIImageView to be placed with respect to the containing view.
  2. keep the width and height of your UIImageView the same

Something like this:

imageView.frame = CGRectMake([desired x coordinate], [desired y coordinate], imageView.frame.size.width, imageView.frame.size.height);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文