internal static NSView LabelControl (string label, float controlWidth, NSControl control) { var view = new NSView (new RectangleF (0, 0, controlWidth, 28)) { AutoresizesSubviews = true, AutoresizingMask = NSViewResizingMask.WidthSizable | NSViewResizingMask.MaxXMargin, }; var text = new NSTextField (new RectangleF (0, 6, 100, 20)) { StringValue = label, DrawsBackground = false, Bordered = false, Editable = false, Selectable = false }; text.SizeToFit (); float textWidth = text.Frame.Width; float textHeight = text.Frame.Height; control.SizeToFit (); var rect = control.Frame; float controlHeight = rect.Height; control.Frame = new RectangleF (textWidth + 5, 0, controlWidth, rect.Height); rect = view.Frame; rect.Width = control.Frame.Width + textWidth + 5; rect.Height = Math.Max (controlHeight, textHeight); view.Frame = rect; view.AddSubview (text); view.AddSubview (control); return view; }
static NSTextField CreateLabel (string text) { var label = new NSTextField () { StringValue = text, DrawsBackground = false, Bordered = false, Editable = false, Selectable = false, }; label.SizeToFit (); return label; }