In iOS 6.0 UILabel supports NSAttributedString, which can be used to underline a Label Programatically.

Use the below code to add underline to a label


    NSMutableAttributedString *attributeString = [[NSMutableAttributedString alloc] initWithString:@"This is an underlined text"];
    [attributeString addAttribute:NSUnderlineStyleAttributeName
                            value:[NSNumber numberWithInt:1]
                            range:(NSRange){0,[attributeString length]}];


Now assign the attribute to the label


   yourLabel.attributedText = [attributeString copy];


Categorized in:

IOS,