私は今、私は私のテキストの垂直方向の配置をしたいし、それがテキストの長さに応じて調整可能である必要があり、NSTextField垂直アライメント
NSView *superView = [[NSView alloc] initWithFrame:NSMakeRect(0, 300, 1400, 500)];
NSTextField *myTextField = [[NSTextField alloc] initWithFrame:NSMakeRect(180, 100, 1000, 300)];
[myTextField setStringValue:myText];
[myTextField setEditable:NO];
[myTextField setBezeled:NO];
[myTextField setDrawsBackground:NO];
[myTextField setSelectable:NO];
[myTextField setFont:[NSFont fontWithName:@"Futura" size:22]];
[superView addSubview:myTextField];
[superView setAutoresizesSubviews:YES];
[myTextField setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self.window.contentView addSubview:superView];
を私はプログラムでこのようNSTextField
を作成したココアのアプリを作成しています。
ご意見はありますか?あなたの提案を教えてください:)
多くのありがとう!
ありがとうsosborn .. !!私はこれを試してみましょう..これに何か問題があれば私はあなたに戻ってきます。 :) – iUser
私は 'RSVerticallyCenteredTextFieldCell.h'と' RSVerticallyCenteredTextFieldCell.m'クラスを持っていますが、私は 'myTextField'を使ってそれを使う方法を知りません。 – iUser
NSControl(NSTextFieldが継承する)を見てください。 setCellClass:というメソッドがあります。 Appleの「コントロールとセルプログラミングガイド」のドキュメントも読むのは良いことです。 – sosborn