void SetUpToolbar() { toolbar = new UIToolbar { TranslatesAutoresizingMaskIntoConstraints = false }; chatInputView = new ChatInputView { TranslatesAutoresizingMaskIntoConstraints = false }; toolbar.LayoutIfNeeded(); View.AddSubview(toolbar); if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0)) { // iPhone X layout var safeGuide = View.SafeAreaLayoutGuide; toolbar.LeadingAnchor.ConstraintEqualTo(safeGuide.LeadingAnchor).Active = true; toolbar.TrailingAnchor.ConstraintEqualTo(safeGuide.TrailingAnchor).Active = true; toolbarHeightConstraint = toolbar.HeightAnchor.ConstraintEqualTo(44); toolbarHeightConstraint.Active = true; toolbarBottomConstraint = toolbar.BottomAnchor.ConstraintEqualTo(safeGuide.BottomAnchor); toolbarBottomConstraint.Active = true; } else { var pinLeft = NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, View, NSLayoutAttribute.Leading, 1f, 0f); View.AddConstraint(pinLeft); var pinRight = NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, View, NSLayoutAttribute.Trailing, 1f, 0f); View.AddConstraint(pinRight); toolbarBottomConstraint = NSLayoutConstraint.Create(View, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, toolbar, NSLayoutAttribute.Bottom, 1f, 0f); View.AddConstraint(toolbarBottomConstraint); toolbarHeightConstraint = NSLayoutConstraint.Create(toolbar, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 0f, 44f); View.AddConstraint(toolbarHeightConstraint); } toolbar.AddSubview(chatInputView); var c1 = NSLayoutConstraint.FromVisualFormat("H:|[chat_container_view]|", 0, "chat_container_view", chatInputView ); var c2 = NSLayoutConstraint.FromVisualFormat("V:|[chat_container_view]|", 0, "chat_container_view", chatInputView ); toolbar.AddConstraints(c1); toolbar.AddConstraints(c2); }