How can I underline text in iOS 6?

前端 未结 2 1760
无人及你
无人及你 2021-01-12 01:22

I am trying to underline some text in a label. However, I do\'t know how to get the range of the entire text in the label. This is what I have so far:

NSMuta         


        
2条回答
  •  失恋的感觉
    2021-01-12 01:58

    For the range you may want to use:

    NSMakeRange (0, mat.length);
    

    Like this:

    NSMutableAttributedString *mat = [self.tableLabel.attributedText mutableCopy];
    [mat addAttributes:@{NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle)} range:NSMakeRange (0, mat.length)];
    self.tableLabel.attributedText = mat;
    

提交回复
热议问题