I am trying to cache the background color set for an NSTextField
via the Interface Builder in a member variable for later usage in another component. At startup, the background color of the NSTextField
is set to transparent.
@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
However, m_userDefinedBackgroundColor
is always black.
The whole CocoaThemes project I am working on is available at GitHub.