I have a window that features one large image, stretched to fit the window (but retaining its proportions). On top of that image is a control panel. When the user moves the cursor away from the control panel, it fades out. When they move it back over it, it fades in.
I messed around with NSViewAnimation to do this but had some troubles, I think because the control panel contains an IKImageBrowserView. I eventually discovered Core Animation was easier and more effective, and so managed to achieve the effect I wanted with this:
if (NSPointInRect([theEvent locationInWindow], [_controlsContainer frame])) {
[[_controlsContainer animator] setAlphaValue:0.95];
} else {
[[_controlsContainer animator] setAlphaValue:0.0];
}
This works perfectly - except that when the control panel fades out, a white area appears where the NSScroller scrollbar for the IKImageBrowserView used to be. Strangely, it only appears over the background of my window, and NOT over the image.
What's the reason for this? I've tried calling setWantsLayer:YES on the contentView of the window, to no avail. An obvious hack would be to make the background of my window a big stretched NSImageView with a plain image in it, but I'd prefer to do it the proper way. Anyone?