【发布时间】:2012-02-22 15:39:28
【问题描述】:
我需要以编程方式制作一些标签和文本字段。我可以到达那里。
//create the file name label
NSTextField* newFileNameLabel = [[NSTextField alloc] initWithFrame:NSMakeRect(objXPos, objYPos, 300.0, 20.0)];
//set properties
[newFileNameLabel setBordered: NO];
[newFileNameLabel setTextColor: [NSColor whiteColor]];
[newFileNameLabel setDrawsBackground:NO];
[newFileNameLabel setEditable:NO];
[newFileNameLabel setStringValue: @"File Name:"];
[vSheetView addSubview:newFileNameLabel];
但我在文档中找不到任何可以让我设置 wrap 属性的内容。在 IB 中,该属性是带有“滚动、换行和截断”选项的布局。 NSTextField 没有设置它的方法,如果我沿着继承链上升,NSControl 也没有。 NSView 有一个 setNeedsLayout 方法,但似乎不相关:
You only ever need to invoke this method if your view implements custom layout
not expressible in the constraint-based layout system by overriding the layout method.
The system invokes this method automatically for all views using constraints for layout.
NSTextFieldCell 也没有任何方法。任何帮助,将不胜感激。
【问题讨论】:
标签: cocoa nstextfield