当前位置: 首页> 科技> 互联网 > 硬件产品开发流程图_腾讯广点通广告投放平台_网络推广营销方法_seo推广培训课程

硬件产品开发流程图_腾讯广点通广告投放平台_网络推广营销方法_seo推广培训课程

时间:2025/7/11 15:23:37来源:https://blog.csdn.net/qq_43441647/article/details/146257085 浏览次数:1次
硬件产品开发流程图_腾讯广点通广告投放平台_网络推广营销方法_seo推广培训课程
1、传入字符串数组,通过NSMutableAttributedString修改匹配文字

可以根据需要搞成匹配单个字符串

- (NSAttributedString *)applyFontSizeToText:(NSString *)text matchStrings:(NSArray<NSString *> *)matchStrings {NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:text];UIFont *font = [UIFont systemFontOfSize:16]; // 目标字体大小for (NSString *match in matchStrings) {NSRange searchRange = NSMakeRange(0, text.length);NSRange foundRange;while (searchRange.location < text.length &&(foundRange = [text rangeOfString:match options:NSCaseInsensitiveSearch range:searchRange]).location != NSNotFound) {[attributedString addAttribute:NSFontAttributeName value:font range:foundRange];[attributedString addAttribute:NSForegroundColorAttributeName value:HexColor(@"#9B9B9B") range:foundRange];// 更新搜索范围,避免死循环searchRange = NSMakeRange(NSMaxRange(foundRange), text.length - NSMaxRange(foundRange));}}return attributedString;
}
调用方法:
NSArray *matchArray = @[@"次/分钟", @"次", @"mmhg", @"小时", @"分钟"];
if (dataString.length != 0) {//避免空字符串self.dataLabel.attributedText = [self applyFontSizeToText:self.dataLabel.text matchStrings:matchArray];
}

关键字:硬件产品开发流程图_腾讯广点通广告投放平台_网络推广营销方法_seo推广培训课程

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: