Pergunta

I have a number of NSImages that I'm rendering in a custom NSView subclass. I'm looking to enlarge theses images as and when the user places their mouse over them and am wondering about the best way to go about doing this.

Currently I'm using the NSView's drawRect: method to composite the images, but also free to render them via NSImageView instances, if that will make things easier. My initial instinct was to setup NSTrackingArea's for each NSImage instance but wanted to ensure I wasn't missing something obvious.

Foi útil?

Solução

Possibly a better way to do this would be to set up the images as Core Animation layers. You can then very easily make the images pop up/enlarge in an animated fashion without having to write the drawing code to do it. Performance will be a lot better also.

As for the mouse tracking, NSTrackingArea is a good way to go.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top