2

How to cross out a string $127.95 in middle. Is there any simple method used to Strike ?

Preethi
  • 195
  • 1
  • 10

3 Answers3

2

As of iOS6 you can use NSAttributedString:

NSDictionary *attributes = @{NSStrikethroughStyleAttributeName: [NSNumber numberWithInteger:NSUnderlinePatternSolid | NSUnderlineStyleSingle]};

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:@"$127.95" attributes:attributes];
tilo
  • 14,009
  • 6
  • 68
  • 85
1

Please have a look at this answer:

CoreText and strikethrough on iPhone

It suggests using Core Text as described here:

http://www.cocoanetics.com/2011/01/befriending-core-text/

Note: this is iOS6 only.

Community
  • 1
  • 1
occulus
  • 16,959
  • 6
  • 53
  • 76
1

Use https://github.com/mattt/TTTAttributedLabel for dropped in UILabel replacement, it does all the Core Text heavy lifting pretty well.

overboming
  • 1,502
  • 1
  • 18
  • 36