Underline text inside uitextview

前端 未结 3 1902
野的像风
野的像风 2021-01-27 09:01

How can i underline text inside uitextview programmatically?

3条回答
  •  旧巷少年郎
    2021-01-27 09:07

    NSMutableAttributedString *attributedString = [self.textView.attributedText mutableCopy];   
    int valueToSet = kCTUnderlineStyleSingle;
    [attributedString addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInt:valueToSet] range:CGMakeRange(0, self.textView.text.length)];
    
    self.textView.attributedText = attributedString;
    [attributedString release];
    

提交回复
热议问题