Rahul
Rahul

Reputation: 509

drawing text using CGContextShowTextAtPoint but text shown is inverted,

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


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


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





 }

I am trying to draw text as shown above "I am Rahul" but when i execute the code,
text gets shown, but it is inverted, why it is happening I am not getting !! help!!

Upvotes: 8

Views: 11044

Answers (2)

Alejandro
Alejandro

Reputation: 3746

This is easier:

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

Upvotes: 14

thierryb
thierryb

Reputation: 3728

You can use this code :

CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));

Upvotes: 26

Related Questions