// Add constraints to imageView void AddConstraints() { var views = new NSDictionary("image", imageView); var metrics = new NSDictionary("width", View.Frame.Width); // Set the width and height to imageView imageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("H:[image(width)]", 0, metrics, views)); imageView.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:[image(width)]", 0, metrics, views)); // Set the imageView in the center of the view View.AddConstraint(NSLayoutConstraint.Create( imageView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterX, 1, 0)); View.AddConstraint(NSLayoutConstraint.Create( imageView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, View, NSLayoutAttribute.CenterY, 1, 0)); }
public override void LoadView() { View = new UIImageView() { UserInteractionEnabled = true, }.Apply(Style.Welcome.Background); View.Add(logoImageView = new UIImageView().Apply(Style.Welcome.Logo)); View.Add(sloganLabel = new UILabel() { Text = "WelcomeSlogan".Tr(), }.Apply(Style.Welcome.Slogan)); View.Add(createButton = new UIButton().Apply(Style.Welcome.CreateAccount)); View.Add(passwordButton = new UIButton().Apply(Style.Welcome.PasswordLogin)); View.Add(googleButton = new UIButton().Apply(Style.Welcome.GoogleLogin)); createButton.SetTitle("WelcomeCreate".Tr(), UIControlState.Normal); passwordButton.SetTitle("WelcomePassword".Tr(), UIControlState.Normal); googleButton.SetTitle("WelcomeGoogle".Tr(), UIControlState.Normal); createButton.TouchUpInside += OnCreateButtonTouchUpInside; passwordButton.TouchUpInside += OnPasswordButtonTouchUpInside; googleButton.TouchUpInside += OnGoogleButtonTouchUpInside; View.AddConstraints( logoImageView.AtTopOf(View, 70f), logoImageView.WithSameCenterX(View), sloganLabel.Below(logoImageView, 18f), sloganLabel.AtLeftOf(View, 25f), sloganLabel.AtRightOf(View, 25f), googleButton.AtBottomOf(View, 20f), googleButton.AtLeftOf(View), googleButton.AtRightOf(View), googleButton.Height().EqualTo(60f), passwordButton.Above(googleButton, 25f), passwordButton.AtLeftOf(View), passwordButton.AtRightOf(View), passwordButton.Height().EqualTo(60f), createButton.Above(passwordButton, 5f), createButton.AtLeftOf(View), createButton.AtRightOf(View), createButton.Height().EqualTo(60f) ); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints(); }
public override void LoadView () { View = new UIImageView () { UserInteractionEnabled = true, } .Apply (Style.Welcome.Background); View.Add (logoImageView = new UIImageView ().Apply (Style.Welcome.Logo)); View.Add (sloganLabel = new UILabel () { Text = "WelcomeSlogan".Tr (), } .Apply (Style.Welcome.Slogan)); View.Add (createButton = new UIButton ().Apply (Style.Welcome.CreateAccount)); View.Add (passwordButton = new UIButton ().Apply (Style.Welcome.PasswordLogin)); View.Add (googleButton = new UIButton ().Apply (Style.Welcome.GoogleLogin)); createButton.SetTitle ("WelcomeCreate".Tr (), UIControlState.Normal); passwordButton.SetTitle ("WelcomePassword".Tr (), UIControlState.Normal); googleButton.SetTitle ("WelcomeGoogle".Tr (), UIControlState.Normal); createButton.TouchUpInside += OnCreateButtonTouchUpInside; passwordButton.TouchUpInside += OnPasswordButtonTouchUpInside; googleButton.TouchUpInside += OnGoogleButtonTouchUpInside; View.AddConstraints ( logoImageView.AtTopOf (View, 70f), logoImageView.WithSameCenterX (View), sloganLabel.Below (logoImageView, 18f), sloganLabel.AtLeftOf (View, 25f), sloganLabel.AtRightOf (View, 25f), googleButton.AtBottomOf (View, 20f), googleButton.AtLeftOf (View), googleButton.AtRightOf (View), googleButton.Height ().EqualTo (60f), passwordButton.Above (googleButton, 25f), passwordButton.AtLeftOf (View), passwordButton.AtRightOf (View), passwordButton.Height ().EqualTo (60f), createButton.Above (passwordButton, 5f), createButton.AtLeftOf (View), createButton.AtRightOf (View), createButton.Height ().EqualTo (60f) ); View.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints (); }