Hi All,
I need ot display a string on the graph. Graph is built using quartz library. Initially I've tried to display text using quartz routines:
I've pasted this code at the beginning of quartzdemo's linedrawing view code, no luck.
Later I've found on the net that iphone doesn't support a lot of fonts and looks like CGContextShowTextAtPoint has its own issues with internationalization.
So, eventually I've used this code for my drawView
Still nothing.
Any idea what am I doing wrong? It can't be that complicated to display a simple text...
Actually I've removed all quartz related code for now.
neither drawinrect nor drawatpoint work... Font is initialized, but no text gets displayed.
I need ot display a string on the graph. Graph is built using quartz library. Initially I've tried to display text using quartz routines:
Code:
CGContextSelectFont (context,"Times-Bold",8,
kCGEncodingMacRoman);
CGContextSetCharacterSpacing (context, 10); // 4
CGContextSetTextDrawingMode (context, kCGTextFillStroke);
CGContextSetRGBFillColor (context, 1, 1, 1, 1); // 6
CGContextSetRGBStrokeColor (context, 1, 1, 1, 1); // 7
CGContextShowTextAtPoint(context, 55, 60,
"test", 4);
CGContextStrokePath(context);
Later I've found on the net that iphone doesn't support a lot of fonts and looks like CGContextShowTextAtPoint has its own issues with internationalization.
So, eventually I've used this code for my drawView
Code:
-(void)drawView:(QuartzView*)view inContext:(CGContextRef)context bounds:(CGRect)bounds
{
NSString* myStr = @"Test";
UIFont* font = [UIFont systemFontOfSize:12.0];
[myStr drawInRect: CGRectMake(160, 240, 100, 130) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
}
Still nothing.
Any idea what am I doing wrong? It can't be that complicated to display a simple text...
Actually I've removed all quartz related code for now.
Code:
-(void)drawRect:(CGRect)rect
{
NSString* myStr = @"Test";
UIFont* font = [UIFont systemFontOfSize:12.0];
//[myStr drawInRect: CGRectMake(160, 240, 100, 130) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
[myStr drawAtPoint:CGPointMake(160,240) forWidth:175 withFont:font minFontSize:10 actualFontSize:NULL lineBreakMode:UILineBreakModeWordWrap baselineAdjustment:UIBaselineAdjustmentNone];
}
neither drawinrect nor drawatpoint work... Font is initialized, but no text gets displayed.