Created
September 29, 2012 01:23
-
-
Save hhyyy9/3802834 to your computer and use it in GitHub Desktop.
文字描边可以达到文字描一圈白边的效果
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//继承UILabel以后重载drawTextInRect | |
- (void)drawTextInRect:(CGRect)rect { | |
CGSize shadowOffset = self.shadowOffset; | |
UIColor *textColor = self.textColor; | |
CGContextRef c = UIGraphicsGetCurrentContext(); | |
CGContextSetLineWidth(c, 1); | |
CGContextSetLineJoin(c, kCGLineJoinRound); | |
CGContextSetTextDrawingMode(c, kCGTextStroke); | |
self.textColor = [UIColor whiteColor]; | |
[super drawTextInRect:rect]; | |
CGContextSetTextDrawingMode(c, kCGTextFill); | |
self.textColor = textColor; | |
self.shadowOffset = CGSizeMake(0, 0); | |
[super drawTextInRect:rect]; | |
self.shadowOffset = shadowOffset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment