문제

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