iOS-5中UIButton标题中带下划线的多行

我想在iOS中创建下划线按钮链接.

我已经用过UIUnderlineButton

所以它给了我以下输出.

请帮助我实现第一张图像下划线按钮.

最佳答案 这应该适用于iOS6及更高版本,使用referencedString:

NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:@"yourTextButton"];
[attrStr addAttribute:NSUnderlineStyleAttributeName value:@(NSUnderlineStyleSingle) range:NSMakeRange(0, [attrStr length])];
[yourButton setAttributedTitle:attrStr forState:UIControlStateNormal];
[[yourButton titleLabel] setNumberOfLines:0];//Multiple Lines
点赞