2017-01-10 50 views
2

我在iPhone 7 Plus和iPhone 6 Plus上看到了奇怪的行爲。這不會發生在模擬器上,只發生在物理設備上。iPhone 7 Plus AVPlayer在其周圍有邊框(顏色與白色不匹配)

如果您有AVPlayer(視頻有白色背景),並且其所附的視圖具有白色背景(音頻播放器比父視圖小),AVPlayer周圍將出現邊框。

這樣做的目標是將視頻混合到背景中以創建一個很酷的效果。除了物理Plus模型設備之外,它在每個設備上都非常出色。

我最好的猜測是有一些完美的白色差異。有誰知道如何解決這個問題或避免這種情況?

+0

我有同樣的問題。 – gohamgx

回答

0

我有這個確切的問題,我的解決方案是在UIView容器中添加AVPlayerLayer,並將掩膜添加到1L插入的playerLayer中。

override func layoutSubview() { 
    super.layoutSubviews() 

    // .. sets frame to players source size 

    let maskLayer = playerLayer.mask ?? CALayer() 
    maskLayer.frame = playerLayer.bounds.insetBy(dx: 1, dy: 1) 
    maskLayer.backgroundColor = UIColor.white.cgColor 
    playerLayer.mask = maskLayer 
}