Reputation: 509
- (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
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
Reputation: 3728
You can use this code :
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
Upvotes: 26