Changing the text on a UISwitch

前端 未结 3 1842
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 07:48

The UISwitch currently says ON and OFF. Can I change the text to YES and NO?

Would it be hard? Or do I just rephrase the question I ask the user?

相关标签:
3条回答
  • 2020-12-03 08:12

    As of iOS 6, you can set

    @property(nonatomic, retain) UIImage *offImage;
    @property(nonatomic, retain) UIImage *onImage;
    

    Docs say:

    This image represents the interior contents of the switch. The image you specify is composited with the switch’s rounded bezel and thumb to create the final appearance.

    The size of this image must be less than or equal to 77 points wide and 27 points tall. If you specify larger images, the edges may be clipped.

    0 讨论(0)
  • 2020-12-03 08:12

    To change the text of an UISwitch e.g. to "Foo/Bar", do the following:

    ((UILabel *)[[[[[[_agreeAgb subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:0]).text = @"Foo";
    ((UILabel *)[[[[[[_agreeAgb subviews] lastObject] subviews] objectAtIndex:2] subviews] objectAtIndex:1]).text = @"Bar";
    
    0 讨论(0)
  • 2020-12-03 08:16

    I've done exactly this in iOS 6 with onImage and offImage, here are the images I used:

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    0 讨论(0)
提交回复
热议问题