Can I rotate a UIView without the black bars?

后端 未结 4 1521
后悔当初
后悔当初 2020-12-11 09:51

I have a UIView that takes up the entirety of the window on the iphone. When it rotates to landscape, the edges get the little black bars until it snaps into place, as i wou

4条回答
  •  旧时难觅i
    2020-12-11 10:13

    UINavigationController and UITabBarController both have system subviews (UINavigationController: UINavigationTransitionView; UITabBarController: UITransitionView and UIViewControllerWrapperView) that have layer.masksToBounds set to YES by default. In order to eliminate the black edges during rotation, you must set these and all other hierarchical view's layer.masksToBounds to NO.

    However, I'm not sure what the effect of altering the above-mentioned system views' layers is, so I recommend resetting their layer.masksToBounds back to YES once you are done animating.

提交回复
热议问题