I have a drawing that I'm happy with on a drawRect, I'm now trying to overlay an image from a specific path, I'd like it to go on top of the current drawing as an overlay. Does anyone know what the best way to do this is, I'd like to be able to set the position and size of this image.
Can this be done with core graphics or should I use an NSImage to do this - would appreciate anyone who can point me in the right direction :)
Your
NSViewdrawRect:method can be called before or after a subclassed implementation ofdrawRect:, which allows you to decide if additional drawing code executes earlier or later and therefore will end up above or below the drawing result ofsuper.as the
flipstate of the view or layer is likely respected when drawing you have to examine the flip state before making your own draw calls. To do this ask forself.flippedorsuper.flippedto adapt to the views flip state like seen above.but there are a lot different ways to mix flipped content with non-flipped.
The following code respects
self.flippedstate when creating anNSImageby locking focus withlockFocusFlipped:method instead of justlockFocus. Also showing other APIs, ps: you don't have to implement imageRepresentation and the following contains more or less pseudo code