How do I draw an NSString at an angle?

前端 未结 2 536
旧时难觅i
旧时难觅i 2020-12-05 21:49

Is there a set of string attributes I can specify that will draw the text at an angle when I call:

[label drawAtPoint:textStart withAttributes:attributes];
<         


        
2条回答
  •  鱼传尺愫
    2020-12-05 22:45

    Here's an example that uses a transform to rotate the drawing context. Essentially it's just like setting a color or shadow, just make sure to use -concat instead of -set.

    CGFloat rotateDeg = 4.0f;
    NSAffineTransform *rotate = [[NSAffineTransform alloc] init];
    
    [rotate rotateByDegrees:rotateDeg];
    [rotate concat];
    
    // Lock focus if needed and draw strings, images here.
    
    [rotate release];
    

提交回复
热议问题