使用CGContextShowTextAtPoint绘制文本但显示的文本是反转的,

Rah*_*hul 8 iphone

  - (void)drawRect:(CGRect)rect {
    CGContextRef  context = UIGraphicsGetCurrentContext();


    CGContextSelectFont(context, "Arial", 24, kCGEncodingMacRoman);


    CGContextShowTextAtPoint(context, 80, 80, "I am Rahul", 7);





 }
Run Code Online (Sandbox Code Playgroud)

我正在尝试绘制文本,如上所示"我是Rahul",但是当我执行代码时,
文本显示,但它被反转,为什么它发生我不会得到!! 救命!!

thi*_*ryb 26

您可以使用此代码:

CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
Run Code Online (Sandbox Code Playgroud)


Ale*_*dro 14

这更容易:

- (void)drawRect:(CGRect)rect {
    NSString* string = @"I am Rahul";
    [string drawAtPoint:CGPointMake(80, 80)
               withFont:[UIFont systemFontOfSize:24]];
}
Run Code Online (Sandbox Code Playgroud)