我只想在横向模式下工作,到目前为止,在应用程序的其余部分中获得适当坐标系的唯一方法是使用以下方法旋转主窗口:
CGAffineTransformMakeRotation(3.1415/2.0f);
它也会旋转所有子视图。
它工作得很好,除了当我想绘制 UILabel 时,帧率下降得像疯了一样。我需要截断和 UILabel 附带的所有漂亮的东西,所以我的问题是,有没有更好的方法进入横向模式或加速文本绘制。我见过一些在横向模式下工作并且仍然有文本的应用程序,所以我想知道......
也许CGAffineTransformMakeRotation(M_PI/2.0f);
改用?这应该会产生一个真正简单的仿射变换矩阵。
非常简单:
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];