首页 > 代码库 > 013-一些开发小技巧

013-一些开发小技巧

1.动态调整文字大小

NSString *dPriceString  = [NSString stringWithFormat:@"¥%d",model.price]NSMutableAttributedString *dPrice = [[NSMutableAttributedString alloc] initWithString: dPriceString];[dPrice addAttribute: NSFontAttributeName value: [UIFont systemFontOfSize: 12] range: NSMakeRange(0, 1)];[dPrice addAttribute: NSFontAttributeName value: [UIFont systemFontOfSize: 18] range: NSMakeRange(1, dPriceString.length - 1)];self.labDiscount.attributedText = dPrice;

 

013-一些开发小技巧