Пример #1
0
        protected override void ConstrainChildren()
        {
            MessageLabel.TrailingAnchor
            .ConstraintLessThanOrEqualToAnchor(ActionButton.LeadingAnchor, -SnackBar.Layout.Spacing).Active = true;
            MessageLabel.LeadingAnchor.ConstraintEqualToAnchor(LeadingAnchor, SnackBar.Layout.PaddingLeading)
            .Active = true;
            MessageLabel.BottomAnchor.ConstraintEqualToAnchor(BottomAnchor, -SnackBar.Layout.PaddingBottom)
            .Active = true;
            MessageLabel.TopAnchor.ConstraintEqualToAnchor(TopAnchor, SnackBar.Layout.PaddingTop).Active = true;

            ActionButton.TrailingAnchor.ConstraintEqualToAnchor(TrailingAnchor, -SnackBar.Layout.PaddingTrailing)
            .Active = true;
            ActionButton.CenterYAnchor.ConstraintEqualToAnchor(CenterYAnchor).Active = true;

            // The following constraint makes sure that button is not wider than specified amount of available width
            ActionButton.WidthAnchor.ConstraintLessThanOrEqualToAnchor(WidthAnchor, ActionButtonMaxWidth, 0f).Active =
                true;

            ActionButton.SetContentCompressionResistancePriority(
                MessageLabel.GetContentCompressionResistancePriority(NSLayoutConstraintOrientation.Horizontal) + 1,
                NSLayoutConstraintOrientation.Horizontal);
        }