3

NSPopUpButtonアプリで、塗りつぶしが黒のカスタム ビューで を作成しました。テキストの色を白にしたいのNSPopUpButtonですが、できないようです。これを行うにはどうすればよいですか?

ありがとう

4

2 に答える 2

0

のサブクラスである-[NSButton setAttributedTitle:]ことを念頭に置いて、 を使用します。属性付きのタイトルの変更可能なコピーを作成し、その前景色を白に設定してから、それを新しい属性付きのタイトルとして設定します。NSPopUpButtonNSButton

NSMutableAttributedString* myTitle = [[button.attributedTitle mutableCopy] autorelease];
NSRange allRange = NSMakeRange( 0, [myTitle length] );
myTitle addAttribute: NSForegroundColorAttributeName
    value: [NSColor whiteColor]
    range: allRange];
button.attributedTitle = myTitle;
于 2015-05-31T02:13:25.787 に答える