本文整理汇总了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;
}