diff --git a/src/iOS.Essentials/AutoLayout/FluentLayoutExtensions.cs b/src/iOS.Essentials/AutoLayout/FluentLayoutExtensions.cs index 3d9aa3a..ada5254 100644 --- a/src/iOS.Essentials/AutoLayout/FluentLayoutExtensions.cs +++ b/src/iOS.Essentials/AutoLayout/FluentLayoutExtensions.cs @@ -5,17 +5,12 @@ // // Project Lead - Stuart Lodge, @slodge, me@slodge.com +using Arbus.iOS.Essentials.BasicViewExtensions; + namespace Arbus.iOS.Essentials.AutoLayout; public static class FluentLayoutExtensions { - [Obsolete("Use AddSubviewsForAutoLayout. The method is to be removed in the future.")] - public static void SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(this UIView view) - { - foreach (var subview in view.Subviews) - subview.TranslatesAutoresizingMaskIntoConstraints = false; - } - public static UIViewAndLayoutAttribute Left(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Left); public static UIViewAndLayoutAttribute Right(this UIView view) => view.WithLayoutAttribute(NSLayoutAttribute.Right); @@ -56,6 +51,7 @@ public static T AddConstraints(this T view, params FluentLayout[] fluentLayou public static T AddConstraints(this T view, IEnumerable fluentLayouts) where T : UIView { + view.DoNotTranslateSubviewsAutoresizingMaskIntoConstraints(); view.AddConstraints(fluentLayouts .Where(fluent => fluent != null) .Select(fluent => fluent.Constraint.Value) diff --git a/src/iOS.Essentials/BasicViewExtensions/UIViewExtensions.cs b/src/iOS.Essentials/BasicViewExtensions/UIViewExtensions.cs index 7ef15e2..f99eb79 100644 --- a/src/iOS.Essentials/BasicViewExtensions/UIViewExtensions.cs +++ b/src/iOS.Essentials/BasicViewExtensions/UIViewExtensions.cs @@ -70,6 +70,9 @@ public static T SetLayoutMargins(this T view, nfloat top, nfloat left, nfloat } public static T AddSubviewsForAutoLayout(this T view, params UIView[] value) where T : UIView + => view.AddViews(value); + + public static T AddViews(this T view, params UIView[] value) where T : UIView { view.AddSubviews(value); return view.DoNotTranslateSubviewsAutoresizingMaskIntoConstraints();