开发者

how to underline UILabel text - iPhone App [duplicate]

This question already has answers here: Closed 9 years ago.

Possible Duplicate:

underline text in UIlabel

I want to underline the UILabel text as hyperlink

UILabel *myLabel = [[U开发者_如何学编程ILabel alloc] initWithFrame:CGRectMake(20.0, 220.0, 160.0, 30.0)];
myLabel.text = @"click here";

How can i make the above string to be underlined ?

Thanks for any help


Create a UIView with a height of 1 and a background color of black, and stick it below the label. Alternatively, you can use CoreText to render an attributed string with an underline, though that requires a bit more work.


You'll have to subclass the UILabel and do the drawing in

- (void)drawRect:(CGRect)rect {
   // Do underlined drawing here...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜