Skip to content

Instantly share code, notes, and snippets.

@matthewryan
Created September 28, 2012 10:22
Show Gist options
  • Save matthewryan/3799030 to your computer and use it in GitHub Desktop.
Save matthewryan/3799030 to your computer and use it in GitHub Desktop.
Simple stroked label by overriding drawInRect:
- (void)drawTextInRect:(CGRect)rect {
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, self.shadowOffset.height);
CGContextSetLineJoin(c, kCGLineJoinRound);
CGContextSetTextDrawingMode(c, kCGTextStroke);
[self.shadowColor set];
[self.text drawInRect:rect withFont:self.font lineBreakMode:self.lineBreakMode alignment:self.textAlignment];
CGContextSetTextDrawingMode(c, kCGTextFill);
[self.textColor set];
[self.text drawInRect:rect withFont:self.font lineBreakMode:self.lineBreakMode alignment:self.textAlignment];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment