2

我只想在横向模式下工作,到目前为止,在应用程序的其余部分中获得适当坐标系的唯一方法是使用以下方法旋转主窗口:

CGAffineTransformMakeRotation(3.1415/2.0f);

它也会旋转所有子视图。

它工作得很好,除了当我想绘制 UILabel 时,帧率下降得像疯了一样。我需要截断和 UILabel 附带的所有漂亮的东西,所以我的问题是,有没有更好的方法进入横向模式或加速文本绘制。我见过一些在横向模式下工作并且仍然有文本的应用程序,所以我想知道......

4

3 回答 3

4

也许CGAffineTransformMakeRotation(M_PI/2.0f);改用?这应该会产生一个真正简单的仿射变换矩阵。

于 2010-01-24T08:42:17.777 回答
2

如果您只想在横向模式下工作,那么从 iPhone OS 2.1 开始,您不需要对主视图应用变换。有关更多详细信息,请参阅此问题的答案。

于 2010-01-24T16:10:28.583 回答
0

非常简单:

    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];
于 2011-10-10T11:38:37.873 回答