UILabel からサブクラス化し、 drawRect メソッドをオーバーライドできます。
- (void)drawRect:(CGRect)rect {
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 207.0f/255.0f, 91.0f/255.0f, 44.0f/255.0f, 1.0f); // RGBA
CGContextSetLineWidth(ctx, 1.0f);
CGContextMoveToPoint(ctx, 0, self.bounds.size.height - 1);
CGContextAddLineToPoint(ctx, self.bounds.size.width, self.bounds.size.height - 1);
CGContextStrokePath(ctx);
[super drawRect:rect];
}
UPD:
iOS 6 の時点で、Apple は UILabel の NSAttributedString サポートを追加したため、はるかに簡単になり、複数の行で機能します。
NSDictionary *underlineAttribute = @{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)};
myLabel.attributedText = [[NSAttributedString alloc] initWithString:@"Test string"
attributes:underlineAttribute];
それでも iOS 4 と iOS 5 をサポートしたい場合は、手動でラベルに下線を引くのではなく、TTTAttributedLabelを使用することをお勧めします。ただし、1 行の UILabel に下線を引く必要があり、サードパーティのコンポーネントを使用したくない場合でも、上記のコードでうまくいきます。