简体   繁体   中英

AVPlayerLayer video “overspilled” when videoGravity set to AVLayerVideoGravityResizeAspectFill

I've set up the custom UIView with AVPlayerLayer as suggested on the Apple Developer Library. Everything works fine, but when I set the videoGravity of the AVPlayerLayer to AVLayerVideoGravityResizeAspectFill, it seems that the parts that are outside of the frame are visible as well. It appears to have an alpha on it too.

I tried setting masksToBounds = YES but it didn't seem to solve the problem.

Any ideas?

You should select the checkbox "Clip subviews" of your AVPlayerLayerView in Xcode. Or you need to set the property accordingly to YES.

I run into the same issue, and fix it by switch to AVLayerVideoGravityResizeAspect. AVLayerVideoGravityResizeAspect ensure the preview layer resize inside your frame bounds.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM