Search code examples
iphoneuiswitch

UISwitch - change from on/off to yes/no


does anyone know of a way I can change the text label for on and off to yes and no.

I did it with

            ((UILabel *)[[[[[[switchControl subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).text = @"Yes";
        ((UILabel *)[[[[[[switchControl subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).text = @"No";

However, with the release of iOS 4.2, this is no longer supported (this probably wasn't recommended by Apple anyway)

My client is insisting on yes/no switches. I'd appreciate any advice!

many thanks


Solution

  • You need to implement your custom UISwitch for that. Or use one of already implemented :) (check this SO question and this post)