- Override
allowsVibrancy
.
Objective-C
@interface VibrancyTextField : NSTextField
@end
@implementation VibrancyTextField
- (BOOL)allowsVibrancy {
return YES;
}
@end
Swift
class VibrancyTextField: NSTextField {
override var allowsVibrancy {
return true
}
}
- Use textColor as Standard Colors. Other colors like RGB or Default Label Color won't work.
Objective-C
VibrancyTextField *testField = [VibrancyTextField new];
testField.stringValue = @"Hello ████████████████████";
testField.textColor = NSColor.systemGrayColor;
[testField release];
Swift
let testField = VibrancyTextField()
testField.stringValue = "Hello ████████████████████"
testField.textColor = .systemGrayColor
Screenshot