开发者

CGContextShowTextAtPoint and white space

Why is it that the following code ignores the white-space?

CGContextShowTextAtPoint and white space

开发者_开发百科UIColor *textColor = [UIColor colorWithRed:153.0/255.0 green:102.0/255.0 blue:51.0/255.0 alpha:1.0];
CGContextSetFillColorWithColor(ctx, [textColor CGColor]);
CGContextSelectFont(ctx, "Helvetica Neue Bold" , 14, kCGEncodingMacRoman);
CGContextSetTextMatrix(ctx, CGAffineTransformMakeScale(1, -1)); 
CGContextSetShadowWithColor(ctx, CGSizeMake(0.0, 1.0), 1.0, [[UIColor whiteColor] CGColor]);
//CGContextSetAllowsAntialiasing(ctx, YES);

NSString *str = @"test1   test2";
CGContextShowTextAtPoint(ctx, 5, 17, [str UTF8String], str.length);

Where as changing the font name to "Helvetica Neue" produces the white space:

CGContextShowTextAtPoint and white space

Does anyone understand whats going on here?


CGContextShowTextAtPoint() is not the right way to show text using CoreGraphics, as misleading as that function name may be. Try CoreText instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜