如何用角度放置文本

时间:2012-08-05 07:19:23

标签: iphone objective-c cocoa-touch

  

可能重复:
  How do I draw an NSString at an angle?

我正在使用

[@"mytext" drawInrect : CGRrectIntegral (rect) withFont:font];

在图片上写文字,我怎样才能每次用不同的角度写文字? (它的滚动图片应与文本一起旋转)。

1 个答案:

答案 0 :(得分:0)

下面的代码会旋转label

- (IBAction)rotate:(id)sender {
    CGContextRef context = UIGraphicsGetCurrentContext();
    [UIView beginAnimations:nil context:context];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(endAnimation)];
    CGAffineTransform rotate = CGAffineTransformMakeRotation(90.0f * (M_PI / 180.0f));
    self.label.transform = rotate;

    [UIView commitAnimations];  
}