button 按钮 字符间距

2023-07-25  本文已影响0人  阳光下的灰尘

NSString *buttonTitle = title;
NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:buttonTitle];

// 设置字符间距(这里使用10作为例子)
[attributedString addAttribute:NSKernAttributeName value:@(2) range:NSMakeRange(0, [buttonTitle length])];

UIFont *boldFont = WLFontBold(14); // 设置所需的粗体大小
[attributedString addAttribute:NSFontAttributeName value:boldFont range:NSMakeRange(0, [buttonTitle length])];

// 将修改后的标题应用到按钮上
[_updataCardBtn setAttributedTitle:attributedString forState:UIControlStateNormal];
上一篇 下一篇

猜你喜欢

热点阅读