Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
421
30
I used the NSGradient method -drawFromCenter: radius: toCenter: radius: options: to draw a gradient in an NSView subclass' drawRect: method. When I do this, the drawing is correctly clipped to the subclass' rect. This works when I'm drawing to the screen or printing but when I save the document to a file, getting an image from the view's superview, the gradient is not clipped to my NSView's rect. I have to draw the gradient instead using -drawInRect: relativeCenterPosition: instead to make it clip correctly. I was surprised to see this because I thought that Cocoa would correctly clip the drawing to the current context for me automatically.Why would this happen?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.