gpt4 book ai didi

cocoa - NSButton 去除文本阴影

转载 作者:行者123 更新时间:2023-12-03 16:32:19 27 4
gpt4 key购买 nike

我使用带有自定义背景的标准 NSButton。黑色标题颜色有白色阴影 - 如何删除它?

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

最佳答案

解决了!

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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com