Skip to content

Commit a91024b

Browse files
authored
Add methods for aligning view edges to the center of other views.
1 parent 7c24dad commit a91024b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Cirrious.FluentLayout/AdvancedFluentLayoutExtensions.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,19 @@ public static FluentLayout ToTopMargin(this UIView view, UIView previous) =>
110110
view.Top().EqualTo().TopMarginOf(previous);
111111

112112
public static FluentLayout ToBottomMargin(this UIView view, UIView previous) =>
113-
view.Bottom().EqualTo().BottomMarginOf(previous);
113+
view.Bottom().EqualTo().BottomMarginOf(previous);
114+
115+
public static FluentLayout ToLeftOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) =>
116+
view.Right().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0));
117+
118+
public static FluentLayout ToRightOfCenterOf(this UIView view, UIView previous, nfloat? margin = null) =>
119+
view.Left().EqualTo().CenterXOf(previous).Minus(margin.GetValueOrDefault(0));
120+
121+
public static FluentLayout AboveCenterOf(this UIView view, UIView previous, nfloat? margin = null) =>
122+
view.Bottom().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0));
123+
124+
public static FluentLayout BelowCenterOf(this UIView view, UIView previous, nfloat? margin = null) =>
125+
view.Top().EqualTo().CenterYOf(previous).Minus(margin.GetValueOrDefault(0));
114126

115127
public static IEnumerable<FluentLayout> FullWidthOf(this UIView view, UIView parent, nfloat? margin = null)
116128
{

0 commit comments

Comments
 (0)