我想为NSString使用CGAffineTransformMakeRotation,我该怎么做?它使用标签,我只需要我的函数字符串。
答案 0 :(得分:3)
CGAffineTransformMakeRotation
用于设置transform
的{{1}}属性,UIView
不是NSString
因此无法转换,它没有概念轮换
您需要在显示时使用UIView
一个例子:
UILabel
答案 1 :(得分:0)
您可以像下面的代码一样旋转文字标签:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib
label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
label.text = @"fof fof fof";
[self.view addSubview: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));
label.transform = rotate;
[UIView commitAnimations];
}