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
14
votes
7 answers

UISwitch, something similar for Mac?

I’m sure most of you are familiar with the UISwitch on iOS. Is their any existing project trying to implement something like a UISwitch for macOS and AppKit? If not, where would one start to make one? I see them frequently and can think of so many…
nosedive25
  • 2,477
  • 5
  • 30
  • 45
14
votes
3 answers

Change Android Switch State

I currently am developing an app that has a menu, and one of the options on the menu is "Settings" where the user can basically decide to turn off sounds and other things like that. I currently have two switches in the Settings activity. Here is the…
user2677095
  • 411
  • 2
  • 8
  • 20
14
votes
3 answers

How to set UISwitch border color?

My app has: [[UIView appearance] setTintColor:[UIColor whiteColor]]; And here is what I have when on: and off: I need to make UISwitch border visible like in Settings.app:
k06a
  • 17,755
  • 10
  • 70
  • 110
13
votes
4 answers

Is there a standard GUI toggle switch in Java?

Is there a standard implementation or library that provides a GUI toggle switch in Swing? I know Swing provides a toggle button, but the UX leaves a bit to be desired. I'm looking for this: Also, is there a canonical term for this type of control?…
cbednarski
  • 11,718
  • 4
  • 26
  • 33
13
votes
8 answers

How to prevent a UISwitch from changing state?

I have a UISwitch that is defined in an .xib file. The event that I'm connected to is "Value Changed". I want the following behavior (essentially warning the user that this function is available in the Full Vesion of the software): allow user to…
milesmeow
  • 3,688
  • 5
  • 35
  • 58
13
votes
3 answers

UISwitch setOn(:, animated:) does not work as document

As Apple's document write, UISwitch's function setOn(on: Bool, animated: Bool) does not send action. It works fine before iOS 10, but it will send action after I call it in iOS 10. I call it in "ValueChanged" event to force switch back, so I got…
codiction
  • 581
  • 5
  • 15
13
votes
3 answers

UISwitch set on/off Image

I want to set my Switch like this: But I try in ios9 , it does not work. I saw in apple UISwitch Class Reference. It says that : Discussion In iOS 7, this property has no effect. How about iOS 9? Any one success? My Code: switch1 =…
YungCheng Su
  • 193
  • 1
  • 1
  • 9
12
votes
4 answers

iOS / iPhone- Hiding one button when another is clicked

I have a settings view in my app which has a couple of buttons (actually UISwitches). If the "off" setting on one of the switches is selected, I'd like to hide the second switch immediately. Can this be done?
Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213
12
votes
4 answers

Swift, Xcode - Increasing the size of a UISwitch

I am making my app 'universal' (used on iPhone and iPad) and I have found ways of increasing the size of everything except for UISwitches. Is there a way of doing so? Any help is greatly appreciated.
mahclark
  • 305
  • 1
  • 2
  • 10
11
votes
2 answers

Add switch in UITableView cell in Swift

How can I embed a UISwitch programmatically in a tableView cell in Swift? I'm doing it like that let shareLocationSwitch = UISwitch() cell.accessoryView = shareLocationSwitch
TAO
  • 180
  • 1
  • 1
  • 11
11
votes
5 answers

From an XCUITest how can I check the on/off state of a UISwitch?

I recently ran into a situation where I needed to be able to check the current on/off state (NOT whether it is enabled for user interaction) of a UISwitch from within an existing bucket of XCUITests, not an XCTest, and toggle it to a pre-determined…
drshock
  • 2,096
  • 2
  • 15
  • 30
11
votes
4 answers

how to change the thumb image in UISwitch in ios7?

i need a to change the Thumb image of UISwitch in ios 7, i googled a lot and find nothing..any suggestions or code will be appreciated,below is my required functionality. i need to change Default UISwitch Thumb image to my Image. Thanks in…
Krishna1251
  • 177
  • 1
  • 10
11
votes
1 answer

UISwitch Doesn't Send valueChanged Event When Changed Programmatically

I have a pair of UISwitches hooked up to a IBAction via the valueChanged event. The valueChanged event is firing fine when the switches are touched. However, if I change one of the switches programmatically it doesn't call my IBAction. -…
robhasacamera
  • 2,967
  • 2
  • 28
  • 41
10
votes
3 answers

UISwitch setSelected not working?

I'm trying to set the UISwitch selected value and it's not responding! Here is my code I set the value to UISwitch. Default value is False. [mailSwitch setSelected:TRUE]; Can someone help me.
HardCode
  • 2,025
  • 4
  • 33
  • 55
10
votes
1 answer

Resize UISwitch in Swift 4

I would like to change the default size of the UISwitch in Swift 4. I have looked at various options but they all relate to v3 and do not work. Please can someone suggest an example that does so programmatically in Swift 4? Thank you, Edit: I have…
user1747021
  • 275
  • 1
  • 4
  • 11
1 2
3
63 64