Пример #1
0
        protected override void Initialize()
        {
            base.Initialize();

            ToggleButton             = new UISwitch();
            ToggleButton.OnTintColor = ApplicationColors.MainColor;
            ToggleButton.TintColor   = ApplicationColors.MainLightColor;
            AddSubview(ToggleButton);
            this.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
            this.AddConstraints(ToggleButton.AtRightOf(this, 15));
            this.AddConstraints(ToggleButton.WithSameCenterY(this));
        }
Пример #2
0
 protected override void SetupConstraints()
 {
     ContentView.AddSubviews(_label, _switch);
     ContentView.SubviewsDoNotTranslateAutoresizingMaskIntoConstraints();
     ContentView.AddConstraints(
         _switch.WithSameCenterY(ContentView),
         _switch.AtRightOf(ContentView, DefaultPadding),
         // using _label.ToLeftOf doesn't seem to work properly. Using _label.AtRightOf instead.
         _label.AtRightOf(ContentView, DefaultPadding + _switch.Bounds.Width + DefaultPadding),
         _label.AtLeftOf(ContentView, DefaultPadding),
         _label.AtTopOf(ContentView, DefaultPadding),
         _label.AtBottomOf(ContentView, DefaultPadding));
 }
Пример #3
0
        public override void UpdateConstraints()
        {
            if (Constraints.Length == 0)
            {
                this.AddConstraints(
                    toggle.AtRightOf(this, 15f),
                    toggle.WithSameCenterY(this),

                    label.AtLeftOf(this, 15f),
                    label.WithSameCenterY(this),
                    label.ToLeftOf(toggle, 5f),

                    null
                    );
            }

            base.UpdateConstraints();
        }