Hallo,
ich versuche seit 2 Stunden einen Text mit Quartz 2D zu zeichen aber ich kriege das nicht hin. ich habe sogar den code von quartz 2D programming Guide ausprobiert und auch ohne erfolg.
was mache ich da falsch?
ich versuche seit 2 Stunden einen Text mit Quartz 2D zu zeichen aber ich kriege das nicht hin. ich habe sogar den code von quartz 2D programming Guide ausprobiert und auch ohne erfolg.
was mache ich da falsch?
Code:
- (void)drawRect:(CGRect)rect {
// Drawing code
CGContextRef context = UIGraphicsGetCurrentContext();
// first draw background
CGRect frame = self.frame;
int w = frame.size.width;
int h = frame.size.height;
NSLog(@"w= %d",w);
NSLog(@"h= %d",h);
CGContextSetRGBFillColor(context, 0.85, 0.85, 0.85, 1.0); // Gray
CGContextFillRect(context,frame);
// Drawing with a black stroke color
CGContextSetRGBStrokeColor(context, 0, 0, 1, 1);
// And draw with a green color
CGContextSetRGBFillColor(context, 0, 1, 0, .5);
// Draw them with a 2.0 stroke width so they are a bit more visible.
CGContextSetLineWidth(context, 2.0);
CGAffineTransform myTextTransform;
//drawing text
myTextTransform = CGAffineTransformMakeRotation(50);
CGContextSetTextMatrix(context,myTextTransform);
CGContextSelectFont(context, "Times-Bold", h/10, kCGEncodingMacRoman); // set font and font size
CGContextSetCharacterSpacing(context, 10);
CGContextSetTextDrawingMode(context, kCGTextFillStroke); // set drawing mode. perform a fill operation on the text
CGContextShowTextAtPoint(context, 40, 0, "test", 4); // draw the text
/*for(int i=1; i<9; i++)
{
// Fill rect convenience equivalent to AddEllipseInRect(); FillPath();
CGContextFillEllipseInRect(context, CGRectMake(w/8, i *(h/12), 20.0, 20.0));
CGContextStrokeEllipseInRect(context, CGRectMake(w/8, i * (h/12), 20.0, 20.0));
CGContextFillEllipseInRect(context, CGRectMake(6*w/8, i *(h/12), 20.0, 20.0));
CGContextStrokeEllipseInRect(context, CGRectMake(6*w/8, i * (h/12), 20.0, 20.0));
}*/
}