Questions tagged [uiswitch]

You use the UISwitch class to create and manage the On/Off buttons which can be seen in iOS, for example, in the preferences (Settings) for such services as Airplane Mode. These objects are known as switches. The UISwitch class declares a property and a method to control its on/off state. As with UISlider, when the user manipulates the switch control a UIControlEventValueChanged event is generated, which results in the control sending an action message.

A UISwitch lets the user turn an option on and off in iOS. UISwitches used throughout the Settings app to let a user quickly toggle a specific setting.

Switches do not need a delegate to function properly; their parent view controller can define their behavior without implementing any delegate protocols.

You can customize the appearance of the switch by changing the color used to tint the switch when it is on or off.

Reference Link : UISwitch Document

For more information about appearance and behavior configuration, see Switches

954 questions
25
votes
3 answers

Custom On/Off Image iOS 7.0 UI Switch

In iOS 7 switches don't allow custom on/off images by default. While I can still set them in the Interface Builder it doesn't show…
Wuzseen
  • 687
  • 3
  • 14
  • 20
24
votes
1 answer

iOS 7.1 Default tint color does not change for UISwitch

I've set default tint color in my storyboard, but I'm getting old blue, default color for my UISwitch component. So I've tried to put [[UIView appearance] setTintColor:APPCOLOR]; inside of my app delegate method -…
Majky
  • 1,943
  • 1
  • 18
  • 30
22
votes
5 answers

How to get the value of a UISwitch?

I am a newbie iOS programmer and I have a problem. I currently work on iOS Core Data and my problem is that I want to insert data into a boolean attribute to a database by taking the value of a UISwitch. The problem is that i don't know what it…
Eristikos
  • 485
  • 4
  • 9
  • 24
22
votes
6 answers

How do I make a UISwitch under iOS 7 not take the background colour of the view behind it?

It looks like this whenever off: While I'd prefer more of a grey background. Do I really have to use a UIImageView?
Doug Smith
  • 29,668
  • 57
  • 204
  • 388
21
votes
3 answers

UISwitch: Swift 3: Programmatically

How can I programmatically add a uiswitch and call an action when on and one when off? Ive been searching for hours now. Can I please have some help? I know how to add the switch but it stays on the screen no matter what scene I'm on. So far, I've…
Robert Smith
  • 233
  • 1
  • 2
  • 11
20
votes
1 answer

How to detect whether UISwitch is on/off?

I am trying to detect when a UISwitch it on / off // .h IBOutlet UISwitch *privateSwitch; @property (nonatomic, retain) IBOutlet UISwitch *privateSwitch; //.m @synthesize privateSwitch; privateSwitch = [[UISwitch alloc] init]; howToDisplay =…
iosfreak
  • 5,228
  • 11
  • 59
  • 102
19
votes
4 answers

How do I disable a UISwitch?

Is this possible to disable a UISwitch? I do not mean putting it in an OFF state, I mean disabling user interaction, and having it appear gray. In my app I have two conditions if (condition == true) { // UISwitch should be enabled } else { …
Pooja
  • 2,162
  • 5
  • 33
  • 64
18
votes
5 answers

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"; …
krisdyson
  • 3,217
  • 7
  • 43
  • 86
18
votes
3 answers

UISwitch setThumbTintColor causing crash (iOS 6 only)?

UPDATE: Got a mail from Apple saying that the bug/issue has been fixed now and the next SDK release won't have this issue. Peace! I have this in the code for my AppDelegate: - (void) customizeAppearance { [[UISwitch appearance]…
Bourne
  • 10,094
  • 5
  • 24
  • 51
17
votes
3 answers

Changing the text on a UISwitch

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?
Sam Jarman
  • 7,277
  • 15
  • 55
  • 100
17
votes
6 answers

Change color of UISwitch appwise

I am using UISwitch in iOS 3 to make a switch element in my app. It has default color set to blue, but I want to change its color to brown. How can I choose a different color for the UISwitch element in iOS 3? How can I choose a different color for…
Ankit Sachan
  • 7,690
  • 16
  • 63
  • 98
16
votes
4 answers

iphone setting and reading state UISwitch

I have a view in which its objects are set from a database and likewise saved to a database. The UITextViews are working great, but I cannot seem to find out how to set the state of a UISwitch. I can change it in the IB but that isnt what I need. …
Mark Worsnop
  • 4,407
  • 15
  • 54
  • 79
16
votes
6 answers

Adding dark mode to iOS app

I am trying to add a theme to my app (a dark theme). So when the user clicks an activity switch it would then make the whole app go into the dark mode. I have hard coded the dark mode just to see what it would look like; however now I would like to…
Jaqueline
  • 465
  • 2
  • 8
  • 25
15
votes
3 answers

Combine UISwitch and UITableViewCell for VoiceOver interaction

In Calendar, when you create a new event, if you tap on the All Day cell with VoiceOver enabled, Siri says "All Day switch button on/off, double tap to change setting". And indeed double tapping will toggle the switch. Also, it's not possible to tap…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
14
votes
3 answers

Programmatically access UISwitch size without adding component

In iOS5, it seems the width of a UISwitch has changed from 94px to 79px. I use the width of that component to calculate how for to the right, to place it in a UITableViewCell. Is there a way to ask, through the iOS API, what the width of a UISwitch…
polesen
  • 713
  • 1
  • 6
  • 18
1
2
3
63 64