internal static void PlatformArrangeHandler(this IViewHandler viewHandler, Rect frame) { var platformView = viewHandler.ToPlatform(); var Context = viewHandler.MauiContext?.Context; var MauiContext = viewHandler.MauiContext; if (platformView == null || MauiContext == null || Context == null) { return; } if (frame.Width < 0 || frame.Height < 0) { // This is a legacy layout value from Controls, nothing is actually laying out yet so we just ignore it return; } var left = Context.ToPixels(frame.Left); var top = Context.ToPixels(frame.Top); var bottom = Context.ToPixels(frame.Bottom); var right = Context.ToPixels(frame.Right); platformView.Layout((int)left, (int)top, (int)right, (int)bottom); viewHandler.Invoke(nameof(IView.Frame), frame); }
internal static void PlatformArrangeHandler(this IViewHandler viewHandler, Rect rect) { var platformView = viewHandler.ToPlatform(); if (platformView == null) { return; } if (rect.Width < 0 || rect.Height < 0) { return; } platformView.Arrange(new global::Windows.Foundation.Rect(rect.X, rect.Y, rect.Width, rect.Height)); viewHandler.Invoke(nameof(IView.Frame), rect); }
internal static void PlatformArrangeHandler(this IViewHandler viewHandler, Rectangle rect) { var platformView = viewHandler.ToPlatform(); if (platformView == null) { return; } // We set Center and Bounds rather than Frame because Frame is undefined if the CALayer's transform is // anything other than the identity (https://developer.apple.com/documentation/uikit/uiview/1622459-transform) platformView.Center = new CoreGraphics.CGPoint(rect.Center.X, rect.Center.Y); // The position of Bounds is usually (0,0), but in some cases (e.g., UIScrollView) it's the content offset. // So just leave it a whatever value iOS thinks it should be. platformView.Bounds = new CoreGraphics.CGRect(platformView.Bounds.X, platformView.Bounds.Y, rect.Width, rect.Height); viewHandler.Invoke(nameof(IView.Frame), rect); }