Skip to content

Latest commit

 

History

History
executable file
·
72 lines (49 loc) · 2.59 KB

File metadata and controls

executable file
·
72 lines (49 loc) · 2.59 KB

Build Status NuGet

Xamarin.iOS.FluentAutoLayoutExtensions is a set of extension methods that will help you write Auto Layout constraints with a lot of ease and speed.

The main goal of this project is to have basic building blocks that will help write less Auto Layout constraint code in a fluent way.

Usage examples

  • Centering a view in the screen:
var centeredView = new UIView { BackgroundColor = UIColor.Blue }.EnableAutoLayout();

View.AddSubview(centeredView);

centeredView.WithSize(200, 200);
centeredView.WithSameCenterX(View);
centeredView.WithSameCenterY(View);

  • Align view in bottom with relative size:
var relativeSizeView = new UIView { BackgroundColor = UIColor.Orange }.EnableAutoLayout();
View.AddSubview(relativeSizeView);

relativeSizeView.WithRelativeWidth(View, 0.5f);
relativeSizeView.WithRelativeHeight(View, 0.5f);
relativeSizeView.WithSameBottom(View);

  • Align view to right of another view:
var relativeSizeView = new UIView { BackgroundColor = UIColor.Orange }.EnableAutoLayout();
var relativePositionView = new UIView { BackgroundColor = UIColor.Purple.ColorWithAlpha(0.3f) }.EnableAutoLayout();

View.AddSubview(relativeSizeView);
View.AddSubview(relativePositionView);

relativeSizeView.WithRelativeWidth(View, 0.5f);
relativeSizeView.WithRelativeHeight(View, 0.5f);
relativeSizeView.WithSameBottom(View);
relativeSizeView.WithSameLeading(View);

relativePositionView.ToRightOf(relativeSizeView);
relativePositionView.WithSameBottom(relativeSizeView);
relativePositionView.WithSize(100, 200);

Documentation

  • You can take a look at the full documentation here.