//设置按钮上的字体大小
btn.titleLabel.font = [UIFont systemFontOfSize: 14.0];
[btn setTitle:@“test” forState:UIControlStateNormal];
// 设置文字位置
btn.contentHorizontalAlignment = UIControlContentHorizonAlignmentLeft;
btn.contentEdgeInsets = UIEdgeInsetsMake(0,10, 0, 0); (如果文字紧贴到边框进行设置, 使文字距离做边框保持10个像素的距离)
// 设置UIButton上字体的颜色
[btn.titleLabel setTextColor:[UIColorblackColor]];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; (这样才对)
//button设置下划线 (用NSMutableAttributedString设置)
NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"月利宝产品详情"];
[str addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:(NSRange){0, [str length]}]; // 下划线样式
[str addAttribute:NSUnderlineColorAttributeName value:[UIColor redColor] range:(NSRange){0, [str length]}]; // 下划线颜色
[str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:(NSRange){0, [str length]}]; // 字体颜色
[self.detailBtn setAttributedTitle:str forState:(UIControlStateNormal)];