How do you stop the UIWindow from clipping to bounds on rotation and showing the 'black frame'?

679 views Asked by At

I'm creating an iOS app on iPad where I have my UIWindow with it's rootViewController having autorotaion for all 4 interface orientations. To the rootViewController.view I have added a view with an AVPlayer. The video which plays in that view is 1280x1280 (the ipad's screen diagonal length). What I want is that when the user rotates the ipad, the video is centered & big enough so that when there is an animated rotation to a different interface orientation the video still fills the corners, instead of having the black frame showing. This would work fine, but i've found that the UIWindow effectively clips to it's bounds and still shows the 'black border' as it autorotates. The black border seen is actually the black of whatever is 'behind' the UIWindow. I've tried setting uiWindow.clipsToBounds = NO & this changes nothing.

I know that it's the UIWindow that is the proplem, because if I change the frame of the UIWindow to be 1280x1280 in size and colour it, there is no longer any black border being shown. However, at that size the rootView of the UIWindow automatically gets set at 0,0,768,1024 which cannot be changed and so I can't center this view in the oversized UIWindow.

How can I solve this problem?

1

There are 1 answers

0
ryecroft On

In iOS 10, setting window.clipsToBounds = YES prevents the black frame showing over the top of lower windows.