简体   繁体   English

如何获取当前的x和y位置以便我可以使用GCRectMake?

[英]How do I get the current x and y position so that I can use GCRectMake?

I have this code inside an animation: 我在动画中有这个代码:

image.frame = CGRectMake(x: x, y: y, width, height)

I need to get the x and y coordinates of an image. 我需要获取图像的x和y坐标。 I found this Objective-C code: 我发现了这个Objective-C代码:

CGPoint origin = imageView.frame.origin;

Once I find the x and y position of the image, I will need to transform it. 一旦找到图像的x和y位置,我将需要对其进行转换。 I will use something like: 我将使用类似的东西:

image.frame = CGRectMake(x-50, y-50, width+500, height+500)

...so that I can move the image around the screen. ...这样我就可以在屏幕上移动图像了。 How do I find the original x and y positions? 如何找到原始的x和y位置?

Do you mean you want this? 你是说你想要这个吗?

var frm: CGRect = imageView.frame
frm.origin.x = frm.origin.x - 50
frm.origin.y = frm.origin.y - 50
frm.size.width = frm.size.width + 500
frm.size.height = frm.size.height + 500
imageView.frame = frm

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Swift:如何在UILabel中找到字母的位置(x,y)? - Swift : How do I find the position(x,y) of a letter in a UILabel? 如何获得UITextField相对于UIScreen的原点y位置? - How can I get UITextField origin y position relative to UIScreen? 如何将Label放在CollectionView中,以便最近的Cell影响Label的“Y”位置? - How can i place the Label inside CollectionView so that nearest Cell affects the “Y” position of the Label? 如何设置SKCameraNode相对于节点的位置x和y? - How can I set an SKCameraNode's position x and y relative to a node? 如何在 UIImageView 中获得 UIImage 的 x 和 y position? - How to get x and y position of UIImage in UIImageView? 如何根据UIButton的y位置获取未知的浮点值 - How do I get a unknown float value based on y position of UIButton 我如何在目标C中的AVPlayerLayer中获得AVPlayer y的位置,高度,宽度 - How can i get AVPlayer y position, height, width in AVPlayerLayer in objective c 欧拉角 Y 值受 X 和 Z 值的影响 - 如何将它们归零以获得“真实”的 y 值? - Euler Angles Y value is affected by X and Z values - how do I zero them out to get a "truthful" y value? 为什么它要求我提供 Y 位置或高度? 我该如何解决? - Why is it asking me for a Y position or a height? How can I fix it? 如果初始帧配置错误,如何在使用 AutoLayout 时获取 UIView 的 (x, y)? - How can I get UIView's (x, y) when using AutoLayout if initial frame was misconfigured?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM