NSTextField
後で別のコンポーネントで使用するために、Interface Builder を介してメンバー変数に設定された背景色をキャッシュしようとしています。起動時の背景色はNSTextField
透明に設定されています。
@implementation CTTextField
- (id)initWithCoder:(NSCoder*)coder {
self = [super initWithCoder:coder];
if (self) {
[self customize];
}
return self;
}
- (id)initWithFrame:(NSRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self customize];
}
return self;
}
- (void)awakeFromNib {
...
[self customize];
}
- (void)customize {
// Store the user defined background color.
// FIXME: The color is not stored.
m_userDefinedBackgroundColor = self.backgroundColor;
// Disable the background color.
self.backgroundColor = [NSColor colorWithCalibratedWhite:1.0f alpha:0.0f];
...
}
@end
ただし、m_userDefinedBackgroundColor
常に黒です。私が取り組んでいるCocoaThemes プロジェクト
全体は、GitHub で入手できます。