效果图:
图片描述


@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]; 

ShevaKuilin
388 声望32 粉丝

世间好物不坚牢,彩云易碎琉璃脆。