給文字添加下劃線

 UILabel *text = [[UILabel alloc]initWithFrame:CGRectMake(135, 70, 200, 60)];
   NSMutableAttributedString *content = [[NSMutableAttributedString alloc] initWithString:@"需要添加下劃線的文字"];
    
   NSRange contentRange = {0,[content length]};
   [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
    
    [text setAttributedText:content];
    [self.view addSubview:text];
發佈了36 篇原創文章 · 獲贊 0 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章