I use standard NSButton with custom background. With black title color there is white shadow - how can I remove it?

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

有帮助吗?

解决方案

Solved!

NSAttributedString documentation says that default value of NSShadowAttributeName is nil, but in this case the button title is drawn with white shadow. Transparent shadow solved problem:

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];
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top