如何在
NSTextField
上实现活力效果
我添加了带有界面生成器的 NSVisualEffectView
并尝试使用 NSAppearance
为标签添加活力
var varLabel = NSTextField()
varLabel.stringValue = "Some"
varLabel.appearance = NSAppearance(named: .vibrantLight)
allowsVibrancy
。@interface VibrancyTextField : NSTextField
@end
@implementation VibrancyTextField
- (BOOL)allowsVibrancy {
return YES;
}
@end
class VibrancyTextField: NSTextField {
override var allowsVibrancy: Bool {
return true
}
}
VibrancyTextField *testField = [VibrancyTextField new];
testField.stringValue = @"Hello ████████████████████";
testField.textColor = NSColor.systemGrayColor;
[testField release];
let testField = VibrancyTextField()
testField.stringValue = "Hello ████████████████████"
testField.textColor = .systemGrayColor