EnterpriseDS Documentation

Class DSSwitch​Table​View​Cell

@available(iOS 13.0, tvOS 13.0, *)
@IBDesignable public final class DSSwitchTableViewCell: UITableViewCell  

A UITableViewCell that implements a UISwitch and label.

When enabled/disabled, the background color changes. In some situations, you may want this color to propagate to the superview automatically.

When added to a UITableView, this class lays out a DSSwitch while passing through the properties directly to it. It honors margins and exposes the underlying DSSwitch for further customization and data access.

For storyboards, add a UITableViewCell to your view and change the class name to DSSwitchTableViewCell.

Set a DSSwitchTableViewCellDelegate to the component to get notified about value changes.

Initialize and set properties as needed.

guard let cell = tableView.dequeue(...) as? DSSwitchTableViewCell else { return }

cell.title = "I agree to this policy"
cell.isOn = false

Note that in the storyboard the checkbox for Accessibility is unchecked, however, it will be enabled by default. Ignore the value of this checkbox. If you want to set this value to false, you must do so in code by setting isAccessibilityElement to false.

Set a DSSwitchTableViewCellDelegate to the component to get notified about value changes.

DSSwitchTableViewCell DSSwitchTableViewCell UITableViewCell UITableViewCell DSSwitchTableViewCell->UITableViewCell

Conforms To




public required init?(coder: NSCoder)  


public override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?)  



@IBOutlet public weak var switchDelegate: DSSwitchTableViewCellDelegate?  

The delegate which receives updates on the DSSwitchTableViewCell's state.


@IBInspectable public var isOn: Bool  

When true, the switch is on. Off otherwise.


@IBInspectable public var title: String  

The text to be displayed next to the switch.


@IBInspectable public var isEnabled: Bool  

Returns true if the switch is enabled and allows selection.