Skip to content

Instantly share code, notes, and snippets.

@amudi
Created December 15, 2010 06:16
Show Gist options
  • Save amudi/741690 to your computer and use it in GitHub Desktop.
Save amudi/741690 to your computer and use it in GitHub Desktop.
[iOS] UILabel+Striketrough
- (void)drawRect:(CGRect)rect {
if (self.text && [self.text length] > 0) {
CGContextRef context = UIGraphicsGetCurrentContext();
[self.textColor set];
[self.text drawInRect:rect withFont:self.font];
CGContextSetStrokeColorWithColor(context, self.textColor.CGColor);
CGContextSetLineWidth(context, 1.0f);
CGContextMoveToPoint(context, CGRectGetMinX(rect), CGRectGetMidY(rect));
CGContextAddLineToPoint(context, CGRectGetMaxX(rect), CGRectGetMidY(rect));
CGContextStrokePath(context);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment