2

我使用具有自定义背景的标准 NSButton。黑色标题颜色有白色阴影 - 我怎样才能删除它?

图片:http: //i.piccy.info/i7/f4ae52b56aad922f0129e4b6bd8688da/4-57-36/57765457/Snymok_ekrana_2013_03_19_v_04_13_58.png

4

1 回答 1

3

解决了!

NSAttributedString 文档说 NSShadowAttributeName 的默认值为 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];
于 2013-03-19T11:17:42.827 回答