gpt4 book ai didi

ios - 在 UIRefreshControl 中将颜色更改为 attributedTitle

转载 作者:可可西里 更新时间:2023-11-01 03:35:28 25 4
gpt4 key购买 nike

我正在寻找一种在 UIRefreshControl 中更改颜色的方法。文本显示在 NSAttributedString 中,因此我尝试使用 CoreText.framework:

 NSString *s = @"Hello";
NSMutableAttributedString *a = [[NSMutableAttributedString alloc] initWithString:s];
[a addAttribute:(id)kCTForegroundColorAttributeName value:(id)[UIColor redColor].CGColor range:NSRangeFromString(s)];
refreshControl.attributedTitle = a;

文本显示正确,但颜色始终是默认的灰色。有什么想法吗?

最佳答案

您应该使用 NSForegroundColorAttributeName,而不是 kCTForegroundColorAttributeName


另外,传递的范围应该是NSMakeRange(0, [s length]);

关于ios - 在 UIRefreshControl 中将颜色更改为 attributedTitle,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12800221/

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