UIButton title字体颜色不一样

_agreementBtn = [uibutton buttonWithType:UIButtonTypeCustom];
        [_agreementBtn setTitle:@"查看《保证金管理协议》" forState:UIControlStateNormal];
        _agreementBtn.titleLabel.font = [UIFont systemFontOfSize:11];
        NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:_agreementBtn.titleLabel.text];
        [_agreementBtn setTitleColor:RGBA(255, 102, 0, 1) forState:UIControlStateNormal];
        [str addAttribute:NSForegroundColorAttributeName value:RGBA(153, 153, 153, 1) range:NSMakeRange(0,2)];
        _agreementBtn.titleLabel.attributedText = str;
        [_agreementBtn setAttributedTitle:str forState:UIControlStateNormal];
        [_agreementBtn addTarget:self action:@selector(agreementBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [_footBgView addSubview:_agreementBtn];

你可能感兴趣的:(ios,uibutton)