domesticcatsoftware / DCRoundSwitch

A 'modern' replica of UISwitch.
MIT License
765 stars 162 forks source link

Various issues #2

Open iosdeveloper opened 13 years ago

iosdeveloper commented 13 years ago

From CocoaControls.com:

Awesome work. I'd love to see a metal gradient knob (rendered in Core Graphics), but I just don't know if that's even possible.

Looking very nice. Is it just me or is the on/off text too far down by 1 pixel?

grgcombs commented 13 years ago

Yep, that was my comment ;-) Looking a little deeper into it, I've found one Core Graphics gradient that looks ok for metal knobs, but to do it right we need some means of creating a conical/angle gradient, which isn't easy. From the sounds of it, it takes a good deal of math to get it, and the chances are it'll draw slow as hell on mobile hardware. I'm still trying to find a workable alternative, or even just a proof of concept, but I didn't take calculus, so I'm probably screwed.

grgcombs commented 13 years ago

Here's the discussion about the gradient on stackoverflow, with code from Rob Napier.

http://stackoverflow.com/questions/6905466/cgcontextdrawanglegradient/6907597#6907597

domesticcatsoftware commented 13 years ago

Ah that looks interesting.. I might throw it in and see what the performance is like. I had to do a lot of workarounds to get this thing performing OK in scrolling lists etc. so I'll see how it works. I think it might actually be OK since the thing is static unless the switch mechanism is actually moving.

grgcombs commented 13 years ago

Don't know if it would do any better as a kernel filter in Core Image, but I'll see if I can get it working as a proof at some point. I'm still trying to find something that could do a conical/angle gradient in iOS, but so far I'm having no luck.