Search code examples
iosiphoneobjective-cuilabelstrikethrough

Format text label when selecting UITableViewCell


I'm working on a shopping list app, and I'm wanting to format the text as strikethrough when selecting a cell, not quite sure how to implement this.

I'm assuming I should toggle this effect in the didSelectRowAtIndexPath: method, but I'm not sure.

Any thoughts?


Solution

  • Hey got some links for you ,might be helpful for you. Also got answer to strike-through for iOS version below 6.

    link1

    link2

    I got below code working for iOS 6 and above

    NSMutableAttributedString *attString=[[NSMutableAttributedString alloc]initWithString:@"PROVIDE_YOUR_STRING"];
    [attString addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInt:2] range:NSMakeRange(0,[attString length])];
    
    _label.attributedText = attString;