I would like to display text with another color in it\'s border (outline). i\'m trying to display a text in MapOverlayView using
[text drawAtPoint:CGPointMake(0
The accepted answer didn't work for me possibly because drawAtPoint:withFont:
is deprecated. I was able to get it to work with the following code:
CGContextRef context = UIGraphicsGetCurrentContext();
CGFloat fontSize = 18.0;
CGPoint point = CGPointMake(0, 0);
UIFont *font = [UIFont fontWithName:@"Arial-BoldMT" size:fontSize];
UIColor *outline = [UIColor whiteColor];
UIColor *fill = [UIColor blackColor];
NSDictionary *labelAttr = @{NSForegroundColorAttributeName:outline, NSFontAttributeName:font};
CGContextSetTextDrawingMode(context, kCGTextStroke);
CGContextSetLineWidth(context, 2.0);
[text drawAtPoint:point withAttributes:labelAttr];
CGContextSetTextDrawingMode(context, kCGTextFill);
CGContextSetLineWidth(context, 2.0);
labelAttr = @{NSForegroundColorAttributeName:fill, NSFontAttributeName:font};
[text drawAtPoint:point withAttributes:labelAttr];