iPhone 7 Plus AVPlayer has border around it (Colors mismatch on white)

920 Views Asked by At

I'm seeing strange behavior on the iPhone 7 Plus and iPhone 6 Plus. This doesn't happen on the simulator, only the physical device.

If you have an AVPlayer (Video has a white background) and the view to which it is attached has a white background (audio player is smaller than parent view) a border will appear around the AVPlayer.

The goal to do this was to blend the video into the background to create a cool effect. Its working great on every device except the physical Plus model devices.

My best guess is there is some perfect white difference. Does anyone know how to fix this or avoid this?

1

There are 1 best solutions below

0
On

I had this exact problem and my solution was to add the AVPlayerLayer inside an UIView container and adding a mask onto the playerLayer with 1pt inset.

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
}