2

I have a Cocoa Swift macOS application that I am developing. I would like to obtain an AVPlayerView with round corners and a shadow. If I enable the shadow in interface builder it shows correctly there but not when I run the app, and drawRect in my subclass is never called so I don't have a clue to where to draw round corners. Any help is much appreciated. Thanks

Alfonso Tesauro
  • 1,730
  • 13
  • 21

2 Answers2

1

You could put the AVPlayerView inside a container view, and apply the cornerRadius and maskToBounds on that view instead of trying to subclass AVPlayerView itself.

ekscrypto
  • 3,718
  • 1
  • 24
  • 38
1

In case it's just about getting rounded corners, you can use this code:

playerView.wantsLayer = true
playerView.layer?.cornerRadius = 10
playerView.layer?.masksToBounds = true

In this code, playerView is an NSPlayerView object.

Ely
  • 8,259
  • 1
  • 54
  • 67