文本来自数据库。我想将它用于按钮并在按钮的文本下划线。我该怎么做?
最佳答案
在 iOS 6 中,NSAttributedString 用于修改文本,您可以将“NSMutableAttributedString”用于使用单个 UIButton 或 UILabel 的多色文本、字体、样式等。
NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:@"The Underlined text"];
// making text property to underline text-
[titleString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [titleString length])];
// using text on button
[button setAttributedTitle: titleString forState:UIControlStateNormal];
关于iphone - UIButton 的按钮文本如何加下划线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5442405/