图片:http: //i.stack.imgur.com/pbzar.png
我想获得 90-270 度的文本(文本“Aroma 7”到“Aroma 17”),旋转 180 度。
我的代码:
for (int i=0; i<24; i++) {
CGContextSaveGState(context);
CGContextRef context = UIGraphicsGetCurrentContext();
NSString *str = [NSString stringWithFormat:@"Aroma %d", i];
CGContextTranslateCTM(context, radius, radius);
CGContextRotateCTM(context, i * 15 * M_PI/180.0);
[[UIColor whiteColor] set];
CGContextTranslateCTM(context, - (radius), -(radius));
CGSize size = [str sizeWithFont:[UIFont fontWithName:@"Helvetica" size:12.0]
constrainedToSize:rect.size
lineBreakMode:(NSLineBreakByWordWrapping)];
[str drawAtPoint:CGPointMake(((radius * 2) - 10) - size.width, radius) withFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
CGContextRestoreGState(context);
}
谢谢您的帮助!