static void PlaceToastNotificationsView(NSView toastNotificationsView, NSView parent) { parent.AddSubview(toastNotificationsView); toastNotificationsView.TranslatesAutoresizingMaskIntoConstraints = false; parent.AddConstraint(NSLayoutConstraint.Create( toastNotificationsView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, parent, NSLayoutAttribute.Trailing, 1f, 2f)); parent.AddConstraint(NSLayoutConstraint.Create( toastNotificationsView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, parent, NSLayoutAttribute.Top, 1f, 2f)); }
public static void DoMergedConstraints(this NSView view, params object[] constraints) { foreach (var o in constraints) { var singleConstraint = o as NSLayoutConstraint; var multipleConstraint = o as NSLayoutConstraint[]; if (singleConstraint != null) { view.AddConstraint(singleConstraint); } else if (multipleConstraint != null) { view.AddConstraints(multipleConstraint); } else { throw new ArgumentException("Unexpected constraint type: " + o.GetType()); } } }