IOS - white font with black border?

Like a white font with a black border?

without using your own font! is it possible?

like here → http://i.stack.imgur.com/ohPQZ.gif

+4
source share
1 answer

What you want can be achieved using Quartz 2D . You can see this sample code provided by Apple. You can also read Documentation .

Choose a font:

 UIFont *font = [UIFont fontWithName:@"Arial" size:14]; CGPoint point = CGPointMake(0,0); 

Get current context:

 CGContextRef context = UIGraphicsGetCurrentContext(); 

Set fill color and stroke color:

 CGContextSetRGBFillColor(context, [[UIColor whiteColor] CGColor]); CGContextSetRGBStrokeColor(context, [[UIColor blackColor] CGColor]); 

Set text drawing mode:

 CGContextSetTextDrawingMode(context, kCGTextFillStroke); 

Save state:

 CGContextSaveGState(context); [@"White Font With Black Border?" drawAtPoint:point withFont:font]; CGContextRestoreGState(context); 
+1
source

Source: https://habr.com/ru/post/1499789/


All Articles