uilabel with outline or stroke
ios4, iphone, uilabel
Solution
It may be helpful to some to add that depending on font and characters, adding:
CGContextSetLineJoin(c,kCGLineJoinRound);
can prevent artifacts from too large a stroke applied to too sharp a character.
Problem
I was wondering how can I create text stroke for UILabel ? is there any possible way ? thank you , ``` #import <Foundation/Foundation.h> @interface CustomLabel : UILabel { } @end #import "CustomLabel.h" @implementation CustomLabel - (void)drawTextInRect:(CGRect)rect { CGSize shadowOffset = self.shadowOffset; UIColor *textColor = self.textColor; CGContextRef c = UIGraphicsGetCurrentContext(); CGContextSetLineWidth(c, 22); 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; //works fine with no warning } ``` now the question is how can i use this subclass with a IBOutlet label on different viewcontrollers . is it right : ``` label = [[CustomLabel alloc] initWithFrame:CGRectMake(0, 0, 190, 190)]; ```