旋转和调整uiview的大小

时间:2017-04-27 19:32:31

标签: ios objective-c uiview rotation

我正在尝试旋转UIview并获取设备的边界。我写了这段代码但是没有得到好结果:

CGAffineTransform affineTransforme = CGAffineTransformMakeRotation(M_PI_2);
    fullScreenView = [[UIViewController alloc] init];
              tmpVideoPlayerview.frame = CGRectMake(0, 0, fullScreenView.view.bounds.size.height , fullScreenView.view.bounds.size.width);
        //tmpVideoPlayerview.frame = fullScreenView.view.bounds;
        // now rotate
         tmpVideoPlayerview.transform = affineTransforme;
        tmpVideoPlayerview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleBottomMargin |
         UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin |
         UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;

        tmpVideoPlayerview.videoContainer.frame = tmpVideoPlayerview.bounds;
        tmpVideoPlayerview.videoContainer.layer.frame = tmpVideoPlayerview.bounds;

        playerLayer = [AVPlayerLayer playerLayerWithPlayer:tmpVideoPlayerview.videoPlayer];
        playerLayer.frame = tmpVideoPlayerview.videoContainer.bounds;
        [tmpVideoPlayerview.avPlayerLayer removeFromSuperlayer];
        [tmpVideoPlayerview.videoContainer.layer addSublayer:playerLayer];

        tmpVideoPlayerview.contentMode = UIViewContentModeScaleToFill;
        [tmpVideoPlayerview updateConstraints];
        [tmpVideoPlayerview layoutIfNeeded];



        [fullScreenView.view addSubview:tmpVideoPlayerview];
        fullScreenView.view.clipsToBounds = YES;
        [self addChildViewController:fullScreenView];
        [self.view addSubview:fullScreenView.view];
        //[self.view updateConstraints];
        //[self.view layoutIfNeeded];
        [[UIApplication sharedApplication] setStatusBarHidden:YES];

tmpVideoPlayerview应旋转90°并调整大小以获得全屏视图的界限。

0 个答案:

没有答案