Rotate UIView in Cocoa Touch

后端 未结 3 1574
逝去的感伤
逝去的感伤 2021-02-02 12:58

I have seen other people who have had this question, but most of the responses aren\'t working on the latest 3.0 build of iPhone OS. Anyway, I\'m wondering how I can programati

相关标签:
3条回答
  • 2021-02-02 13:13

    this works for me

     CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI_2);
     self.view.transform = transform;
    
     // Repositions and resizes the view.
     CGRect contentRect = CGRectMake(0,0, 480, 320);
     self.view.bounds = contentRect;
    
    0 讨论(0)
  • 2021-02-02 13:23

    I had success with that:

    CATransform3D rotationTransform = CATransform3DIdentity;
    [view.layer removeAllAnimations];
    rotationTransform = CATransform3DRotate(rotationTransform, angle, 0.0, 0.0, 1);
    view.layer.transform = rotationTransform;
    
    0 讨论(0)
  • 2021-02-02 13:29

    Not sure if this is considered private API, so you may not want to use it, but if you want to force the orientation to change without tilting the device, you can try calling:

    [[UIDevice currentDevice] performSelector:@selector(setOrientation:)
                          withObject:(id)UIInterfaceOrientationLandscapeLeft];
    

    I have not tested that it still works on 3.1.2. though I know it works on 3.0.

    0 讨论(0)
提交回复
热议问题