本文整理匯總了C#中MonoMac.AppKit.NSTextField.SizeToFit方法的典型用法代碼示例。如果您正苦於以下問題:C# NSTextField.SizeToFit方法的具體用法?C# NSTextField.SizeToFit怎麽用?C# NSTextField.SizeToFit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MonoMac.AppKit.NSTextField
的用法示例。
在下文中一共展示了NSTextField.SizeToFit方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LabelControl
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;
}
示例2: CreateLabel
static NSTextField CreateLabel (string text)
{
var label = new NSTextField () {
StringValue = text,
DrawsBackground = false,
Bordered = false,
Editable = false,
Selectable = false,
};
label.SizeToFit ();
return label;
}