我使用带有自定义背景的标准 NSButton。黑色标题颜色有白色阴影 - 如何删除它?
最佳答案
解决了!
NSAttributedString 文档说 NShadowAttributeName 的默认值为 nil,但在这种情况下,按钮标题是用白色阴影绘制的。透明阴影解决的问题:
NSShadow *shadow = [[NSShadow alloc] init];
[shadow setShadowColor:[NSColor colorWithDeviceWhite:1.0 alpha:0.0]];
NSDictionary *attrsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
shadow, NSShadowAttributeName, nil];
NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:_customTitle attributes:attrsDictionary];
[mybutton setAttributedTitle:attrString];
关于cocoa - NSButton 去除文本阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15490517/