Xamarin.ios 如何将UIImage 100px仅向右移动

Xamarin.ios 如何将UIImage 100px仅向右移动,xamarin.ios,xamarin,Xamarin.ios,Xamarin,在Xamarin iOS中,如何将图像从当前位置移动到右侧100px?我知道我应该使用边界,但我无法获得真正提供任何有用信息的强度。我在谷歌上搜索了一下,找不到多少。假设您指的是UIImageView,您可以在其Frame属性上使用Offset(dx,dy)方法。如果您的UIImageView被调用为imageView: var frame = imageView.Frame; frame.Offset(100,0); // offset 100px horizontal, 0 px verti

在Xamarin iOS中,如何将图像从当前位置移动到右侧100px?我知道我应该使用边界,但我无法获得真正提供任何有用信息的强度。我在谷歌上搜索了一下,找不到多少。

假设您指的是
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)
将不起作用

它根本没有移动图像。你能显示你正在使用的代码吗?我这里有一个很小的复制程序,它可以像预期的那样工作。可能是我的ViewDidLoad()中的代码首先运行吗?var frame=this.imgPin.frame;Console.WriteLine(“A:+frame.Left.ToString());帧偏移量(100200);//偏移量100px水平,0 px垂直this.imgPin.Frame=Frame;//将图像的边框设置为新位置。Console.WriteLine(“B:+frame.Left.ToString());即使尝试了这个,也什么也没有:this.imgPin.Frame=newcoregraphics.CGRect(10,10,10,10);