Is fast UILabel rotation possible?
I want to work in landscape mode only and so far the only way I can get the appropriate coordinate frame in the rest of the application is by rotating the main window using:
CGAffineTransformMakeRotation(3.1415/2.0f);
which rotates all subviews as well.
It works great, except when I want to draw UILabel, frame rate drops like crazy. I need the truncation and all those pretty things that come with UILabel so my question is, is there a better way of going into landscape mode or 开发者_如何转开发speeding up the text drawing. I've seen some applications that work in landscape mode and still have text, so I wonder...
Maybe use CGAffineTransformMakeRotation(M_PI/2.0f);
instead? This should produce a truly simple affine transform matrix.
If all that you want to do is work in landscape mode, as of iPhone OS 2.1 you don't need to apply a transform to your main view. See this answer to this question for more detail.
Very Simple:
myLabel.text = @"Text To Rotate";
//myLabel is UILabel, which i want to Rotate.
myLabel.textColor = self.xValuesColor;
myLabel.backgroundColor = [UIColor redColor];
myLabel.textAlignment = UITextAlignmentCenter;
CATransform3D landscapeTransform = CATransform3DIdentity;
landscapeTransform = CATransform3DRotate(landscapeTransform,-90, 0, 0, 1);
// -90 is angle to rotate, you can change it according to your requirement.
myLabel.layer.transform = landscapeTransform;
[self addSubview:myLabel];
[myLabel release];
精彩评论