積累好的東西,以後都是你的,哈哈哈哈哈~~~~
沉迷技術,無法自拔!!!!
最近在做顯示金額的樣式!!!
以下是方法:
#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];
=====================================================================
啦啦啦啦啦啦啦,就這樣完成啦~~~