Best approach for custom button using layers?
Best approach for custom button using layers?
- Subject: Best approach for custom button using layers?
- From: Graham Cox <email@hidden>
- Date: Sun, 06 Apr 2014 17:25:34 +1000
I want to make some custom buttons to replace the standard checkbox, and maybe others. I also want to make use of Core Animation layers to animate aspects of these.
Looking at the current model of NSControl + NSCell subclasses (in this case NSButton + NSButtonCell), they bring along much baggage. That in itself isn't a problem as such, but the whole design seems to be not such a great fit for a CA layer approach - the cells are supposed to draw when told to by the hosting control, and fitting the layer model into this seems like hard work - at what point does the cell add its layers to the view, for example? Both the control and the cell will need subclassing so that I can make the control a layer-hosting view not a layer-backed one, and there's no telling whether that's going to interfere with anything it does already.
The alternative is just to subclass NSView and bypass the whole NSControl hierarchy. For the things I want to do, which are simple, this is awfully tempting. It has one obvious downside and that is IB support for hooking up actions, which appears to rely on the object being an NSControl.
What's the best advice here? Have others managed to make layer-based controls and what's the best approach? I've created custom NSCell subclasses in the past, but this is the first time I want to make them animatable using layers. I don't think I want to use these controls in matrixes or tables, so there's nothing that absolutely compels me to follow the control + cell model.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden