I am looking to create a simple colour palette, and have setup a grid of buttons in interface builder.
I’d like a user to be able to interact with the palette (buttons), by selecting any button, then drag the finger between buttons (firing events on entering and exiting a button and changing the selected colour with each event). Is this possible?
For example, the user touches down on a blue button (the color is updated), then drags the finger over to a green button (the color is updated).
The “Touch Drag Enter” and “Touch Drag Exit” events appear to only fire if a user’s initial selection was on the sender (does not allow dragging between two buttons). Thanks!
I created a simple app that does what you want. You can find the source at:
http://github.com/st3fan/iphone-experiments/tree/master/Miscellaneous/ColorPalette/
It is simply a container view (
PaletteView) with a bunch of subviews that have specific colors. When thePaletteViewreceives a touch, it find the view that is under the touch and then tells it’s delegate (PaletteViewDelegate) that the color changed.Tested on an iPhone 4 with 4.0.2.