使用变换旋转后,UI 视图不会移动到屏幕边界

After using transform to rotate, UI view doesn't move to screen bounds

晚上好!我有一个仅用于纵向的应用程序,但我需要在一个控制器中横向播放视频。视频在 videoView UIView 中播放。

在情节提要中,视图距离 window 边界 5 毫米。 为了尝试实现这一点,我旋转 videoView,现在视频横向播放,但问题是它没有填满屏幕,它似乎保持旋转前的宽度并压扁以适应屏幕横向。

我需要让 UIview 在旋转后填满屏幕...这可能吗?我已经尝试了故事板中我能想到的一切,并尝试在旋转后在下面编码以调整大小,但似乎没有任何改变 UIView 的大小。

override func viewDidLoad() {
            super.viewDidLoad()
            videoView.transform = CGAffineTransform(rotationAngle: 45 * .pi/90.0)
            videoView.frame.size.height = view.frame.height
            videoView.frame.size.width = view.frame.width

    }

非常感谢所有建议。

Try this

override func viewDidLoad() 
{
super.viewDidLoad()
viewVideo.transform = CGAffineTransform(rotationAngle:CGFloat(M_PI_2))
viewVideo.frame = CGRect(x: 0 , y: 0, width: iPhoneWidth, height: iPhoneHeight)   
}

where 
iPhoneWidth  =  UIScreen.main.bounds.size.width
iPhoneHeight =  UIScreen.main.bounds.size.height