NSScrollView
IBから作成されたシンプルなものがあります。.h ファイルからリンクしました。これは次のIBOutlet
とおりです。
IBOutlet NSScrollView *scroller;
私の .m では、次のNSTextField
ようにプログラムで挿入します。
NSTextField *dateTextField = [[NSTextField alloc]initWithFrame:NSMakeRect(30,yPos - kBreakHeight - 15, 100, kBreakHeight)];
[dateTextField setBordered:NO];
[dateTextField setEditable:NO];
[dateTextField setBackgroundColor:[NSColor clearColor]];
[dateTextField setAlignment:NSLeftTextAlignment];
[dateTextField setFont:[NSFont fontWithName:kAppFontBold size:11]];
[dateTextField setTextColor:[NSColor colorWithCalibratedRed:33/255.0 green:33/255.0 blue:33/255.0 alpha:1]];
[dateTextField setStringValue:dateString];
[[scroller documentView] addSubview:dateTextField];
残念ながら、私のビューの最初のランチでは、テキスト フィールドは正しい位置にありません (ただし、documentView の他の要素はそうです)。位置は、ウィンドウのサイズを変更した場合にのみ正しいです。
打ち上げ時に正しい位置を保つ方法はありますか?