2
我使用自定义背景的标准NSButton。黑色标题颜色有白色阴影 - 我该如何删除它?NSButton删除文字阴影
我使用自定义背景的标准NSButton。黑色标题颜色有白色阴影 - 我该如何删除它?NSButton删除文字阴影
解决了!
NSAttributedString文档说NSShadowAttributeName的默认值为零,但在这种情况下,按钮标题用白色阴影绘制。解决透明阴影问题:
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];