Skip to content

Instantly share code, notes, and snippets.

@jebai0521
Last active August 29, 2015 14:08
Show Gist options
  • Select an option

  • Save jebai0521/a4b10b410bd1c2a70afe to your computer and use it in GitHub Desktop.

Select an option

Save jebai0521/a4b10b410bd1c2a70afe to your computer and use it in GitHub Desktop.
NSNumber* old = @(600);
NSNumber* new = @(300);
NSString* oldStr = [NSString stringWithFormat:@"¥%@ ", old];
NSString* newStr = [NSString stringWithFormat:@"¥%@ ", new];
NSAttributedString* oldAttrStr = [[NSAttributedString alloc] initWithString:oldStr attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleNone), NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}];
NSAttributedString* newAttrStr = [[NSAttributedString alloc] initWithString:newStr attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleSingle), NSForegroundColorAttributeName:[UIColor grayColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}];
NSMutableAttributedString* full = [[NSMutableAttributedString alloc] initWithAttributedString:oldAttrStr];
[full appendAttributedString:[[NSAttributedString alloc] initWithString:@" - " attributes:@{NSStrikethroughStyleAttributeName:@(NSUnderlineStyleNone), NSForegroundColorAttributeName:[UIColor grayColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:20]}]];
[full appendAttributedString:newAttrStr];
[_label setAttributedText:full];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment