效果图:
@interface XSRecommendedPrivilegeViewController ()
@property (weak, nonatomic) IBOutlet UIButton *payButton;
@property (weak, nonatomic) IBOutlet UILabel *termsLabel;//服务条款
@end
@implementation XSRecommendedPrivilegeViewController
-(void)viewDidLoad {
[super viewDidLoad];
self.payButton.layer.masksToBounds = YES;
self.payButton.layer.cornerRadius = 7;
NSString * changeString = @"《倾听者套餐服务条款》";
NSString * termsString = [NSString stringWithFormat:@"点击下一步代表您同意%@", changeString];
NSMutableAttributedString * attString = [[NSMutableAttributedString alloc] initWithString:termsString];
NSRange strRange = {[changeString length],[changeString length]};//控制下划线的开始和结束的范围
[attString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:strRange];//划线
[attString addAttributes:@{NSForegroundColorAttributeName:kColor} range:[termsString rangeOfString:changeString]];//改变范围颜色
[self.termsLabel setAttributedText:attString];
}
//同理改变button的内容
//[_awardDisplayBtn setAttributedTitle:str forState:UIControlStateNormal];
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。