function CGAffineTransformMakeRotation and CGAffineTransformMake can not work together using quartz-2d
It seems that function CGAffineTransformMakeRotation and CGAffineTransformMake can not work together.
CGContextSetTextMatrix (context, CGAffineTransformMakeRotation (degreesToRadians(40)));
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
I got this
CGContextSetTextMatrix (context, CGAffineTransformMakeRotation (degreesToRadians(40)));
CGContextSetTextMatrix(context, CGAffineTransformMake(1.0,0.0, 0.0, -1.0, 0.0, 0.0));
I got this
What I w开发者_JAVA百科ant to implement is the words are readable and have 40 degree with X-axis.
Thanks!
The CGContextSetTextMatrix sets the text matrix and each call replaces the previous matrix, it does not combine them. You need to combine the matrixes and then set the text matrix:
CGAffineTransform ctm = CGAffineTransformMake(1, 0, 0, 1, 0, 0);
ctm = CGAffineTransformTranslate(ctm, xTextPos, yTextPos);
ctm = CGAffineTransformScale(ctm, 1, -1);
ctm = CGAffineTransformRotate(ctm, -degreesToRadians(40));
CGContextSetTextMatrix(ctx, ctm);
精彩评论