0

I've found this Former topic about how to customize a switch on iOS 6.

But I don't know how to use the answer :

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

Where do I have to put these 2 lines ? In a .h file or .m file ? In the ViewController file where my switch is ?

Moreover, how can I set links between my images and these two lines (I have to call my images "offimage.png" and "onimage.png" ?)

Community
  • 1
  • 1
GoldXApp
  • 2,397
  • 3
  • 17
  • 26

3 Answers3

1

Under iOS 7 the On-and Off-Image are not working anymore.

https://developer.apple.com/library/ios/documentation/uikit/reference/UISwitch_Class/Reference/Reference.html

"In iOS 7, this property has no effect."

Baby Groot
  • 4,637
  • 39
  • 52
  • 71
Toprakete
  • 23
  • 5
0

onImage and offImage are properties of UISwitch - you don't add the code to your code. When you have created an instance of UISwitch you can then set the on and off images by setting those properties to the appropriate UIImage instances.

Wain
  • 118,658
  • 15
  • 128
  • 151
0

To complete my question, I have just to put this line in the .m file :

switch_name.onImage=[UIImage imageNamed:@"image_name.jpg"];
GoldXApp
  • 2,397
  • 3
  • 17
  • 26