如何将 UIImage 仅向右移动 100px

How to move a UIImage 100px to the right only

在 Xamarin iOS 中,如何简单地将图像从当前位置向右移动 100 像素?我知道我应该使用边界,但我无法真正提供任何有用的东西。我已经用谷歌搜索了,但我找不到太多东西。

假设您的意思是 UIImageView,您可以在其 Frame 属性 上使用 Offset(dx,dy) 方法。如果您的 UIImageView 被称为 imageView

var frame = imageView.Frame;
frame.Offset(100,0); // offset 100px horizontal, 0 px vertical
imageView.Frame = frame; // set the frame of the image to the new position.

请注意,您必须将框架对象放入一个单独的变量中。也就是说,imageView.Frame.Offset(100,0) 将不起作用。