简体   繁体   中英

MonoTouch: Where is Frame.Origin?

I am trying to translate this centering code snip in Objective-C into MonoTouch

imageView.frame.origin.x = CGRectGetMidX(view.bounds) - 
            CGRectGetMidX(imageView.bounds)

But can't find where Origin is.

MonoTouch maps GCRect to System.Drawing.RectangleF since it's closer to what .NET developers have been using (eg System.Drawing / Windows Forms...).

As such imageView.frame.origin.x will become imageView.Frame.Location.X which can simplified by imageView.Frame.X .

If you add using MonoTouch.CoreGraphics; to your source file you'll get extension methods that will provide you with CGRectGetMidX replacement, eg

views.Bounds.GetMidX ()

So

imageView.frame.origin.x = CGRectGetMidX(view.bounds) - CGRectGetMidX(imageView.bounds);

should become

imageView.Frame.X = view.Bounds.GetMidX () - imageView.Bounds.GetMidX ();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM