Search code examples
cocoa-touchios4core-graphicsuislideruiswitch

UISlider or UISwitch with a stationary mask?


I've found a gorgeous switch that I'd like to implement in iOS. The artist (@jasonlong) has kindly shared his PSD of the components at 365psd.com, along with a crafty little javascript as a demo.

Now, here's where I get into trouble... The custom UISlider and UISwitch examples I've found seem to rely on a track that's stationary with a movable knob/toggle. In the switch below, it would require a knob/track to animate behind a mask that also passes through touch events.

I've never been much of an interface coder, but this cute little bugger is just to awesome to leave alone. Can someone point me in the right direction?

Metal Slider Switches


Solution

  • I suggest just having the background stationary, and just fade between them? Sliding the track is probably not going to work so well, as you can still see the green/white around the edge of the knob.