设置多行文字,每行文字大小,颜色不一样,这个是比较常见的
1.导入YYKit框架
2.写代码
NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
style.lineSpacing = 3;//行距
//第一行的属性字符串
NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString: @"立即支付" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.f],NSForegroundColorAttributeName:RGB(102, 102, 102),NSParagraphStyleAttributeName:style}];
//第二行的属性字符串
NSMutableAttributedString *attri2 = [[NSMutableAttributedString alloc] initWithString: @"\n(第二行)" attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:8.f],NSForegroundColorAttributeName:RGB(102, 102, 102),NSParagraphStyleAttributeName:style}];
[attri appendAttributedString:attri2];
self.payBtn.titleLabel.attributedText = attri;
self.payBtn.titleLabel.numberOfLines=0;
self.payBtn.titleLabel.textAlignment =NSTextAlignmentCenter;