0
我想爲標籤添加下劃線。爲此,我使用了下面的代碼。我正在使用自定義字體:標籤在線不顯示
headingLbl.font=[UIFont fontWithName:GZFont size:20.0f];
NSMutableAttributedString *gpsSearch = [[NSMutableAttributedString alloc] initWithString:@"GPS Search"];
[gpsSearch addAttribute:(NSString*)kCTUnderlineStyleAttributeName
value:[NSNumber numberWithInt:kCTUnderlineStyleSingle]
range:(NSRange){0,[gpsSearch length]}];
self.headingLbl.attributedText = gpsSearch;
self.headingLbl.textColor = [UIColor blackColor];
這是一個多行'UILabel'?因爲如果不是,那麼你可以覆蓋'UILabel'類的'drawRect' - 鏈接:http://stackoverflow.com/questions/2711297/underline-text-in-uilabel – staticVoidMan