Make link in UILabel.attributedText *not* blue and *not* underlined

前端 未结 11 1244
终归单人心
终归单人心 2020-12-24 05:18

I want some words within my OHAttributedLabel to be links, but I want them to be colors other than blue and I don\'t want the underline.

This is giving me a blue lin

11条回答
  •  遥遥无期
    2020-12-24 05:45

    Here's is my improved version of Ramsel's already great answer. I believe it's much more readable, and I hope it will come to good use.

    label.linkAttributes = @{ NSForegroundColorAttributeName: [UIColor whiteColor],
                              NSUnderlineStyleAttributeName: [NSNumber numberWithInt:NSUnderlineStyleSingle] };
    

    Here's a list of other attibute names.

提交回复
热议问题