Can anyone guide me in the correct way to build a colored bubble/circle programmatically?
I can’t use images as I need it to be able to be any color depending on user interaction.
My thought was maybe to make a white circle image and then overlay a color on top of it. However I am not sure if this would work, or how to really go about it.
If someone could point me the right direction I would appreciate it.
Create an NSView subclass that holds an NSColor as an ivar. In the drawRect method, create an NSBezierPath of the appropriate size, using the view’s bounds. Then set the color
[myColor set]and fill the path[myPath fill]. There’s a lot more you can do, such as set transparency, a border, and so on and so on, but I’ll leave that to the docs unless you have a specific question.To use the NSView subclass, just drag a view object onto your nib, and choose the name of your subclass in custom class in IB’s inspector. You’ll need to also set an outlet to it in your controller, so you can change the color as needed.