积累好的东西,以后都是你的,哈哈哈哈哈~~~~
沉迷技术,无法自拔!!!!
最近在做显示金额的样式!!!
以下是方法:
#pragma mark - amount style
- (void)amountLabelTextFont:(UILabel *)titleLabel
{
NSMutableAttributedString *attString = titleLabel.attributedText.mutableCopy;
UIFont *firstPartFont = [UIFont systemFontOfSize:26 weight:UIFontWeightThin];
UIFont *secondPartFont = [UIFont systemFontOfSize:13 weight:UIFontWeightThin];
NSRange amountPointRange = [attString.string rangeOfString:@"."];
if (amountPointRange.location != NSNotFound) {
[attString addAttribute:NSFontAttributeName value:firstPartFont range:NSMakeRange(0, amountPointRange.location)];
[attString addAttribute:NSFontAttributeName value:secondPartFont range:NSMakeRange(amountPointRange.location, attString.length - amountPointRange.location)];
} else {
[attString addAttribute:NSFontAttributeName value:firstPartFont range:NSMakeRange(0, attString.length)];
}
titleLabel.attributedText = attString.copy;
}
下面是调用方法:
[self amountLabelTextFont:self.CNYBalanceLabel];
=====================================================================
啦啦啦啦啦啦啦,就这样完成啦~~~