Skip to content

Commit

Permalink
draw strikethrough line
Browse files Browse the repository at this point in the history
  • Loading branch information
usami-k committed Feb 10, 2014
1 parent 383f5ea commit fefe246
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Lib/SETextView.m
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,32 @@ - (void)enumerateLinksUsingBlock:(void (^)(SELinkText *link, BOOL *stop))block
}
}

- (void)drawTextDecorations
{
[self.attributedText enumerateAttribute:NSStrikethroughStyleAttributeName inRange:NSMakeRange(0, self.attributedText.length) options:kNilOptions usingBlock:^(id value, NSRange range, BOOL *stop) {
if (!value) {
return;
}

for (SELineLayout *lineLayout in self.textLayout.lineLayouts) {
CGRect strikeRect = [lineLayout rectOfStringWithRange:range];
if (!CGRectIsEmpty(strikeRect)) {
if (self.textColor) {
[self.textColor set];
}
else {
[[UIColor blackColor] set];
}

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(CGRectGetMinX(strikeRect), CGRectGetMidY(strikeRect))];
[path addLineToPoint:CGPointMake(CGRectGetMaxX(strikeRect), CGRectGetMidY(strikeRect))];
[path stroke];
}
}
}];
}

- (void)drawTextAttachmentsInContext:(CGContextRef)context
{
NSMutableSet *attachmentsToLeave = [[NSMutableSet alloc] init];
Expand Down Expand Up @@ -912,6 +938,10 @@ - (void)drawRect:(CGRect)dirtyRect

[self highlightClickedLink];

#if TARGET_OS_IPHONE
[self drawTextDecorations];
#endif

[self drawTextAttachmentsInContext:context];

#if TARGET_OS_IPHONE
Expand Down

0 comments on commit fefe246

Please sign in to comment.