Getting the screen's size in a macOS screensaver
As a hobby project, I’ve been writing a screensaver for my Mac that displays my photos with a caption and date taken. To get the width and height of the screen so that I could size the image correctly, I used this code in my ScreenSaverView:
self.screenWidth = frame.size.width
self.screenHeight = frame.size.height
However, I discovered that with two or more screens, sometimes the frame size returned was wrong and so the photo was either too small in the screen, showing a black area, or larger than the screen.
To make it more reliable, I’ve change the code to use self.bounds instead:
self.screenWidth = self.bounds.width self.screenHeight = self.bounds.height
Reading around, this is what I should have used in the first place!