Skip to content

Instantly share code, notes, and snippets.

@exorcyze
Created January 8, 2021 22:21
Show Gist options
  • Save exorcyze/f1dace7d4988650bda7b326d27af83ed to your computer and use it in GitHub Desktop.
Save exorcyze/f1dace7d4988650bda7b326d27af83ed to your computer and use it in GitHub Desktop.
//
// SettingsCell
// Created / Copyright © : Mike Johnson, 2021
//
import Foundation
import UIKit
// MARK: - Lifecycle
class SettingsCell: UITableViewCell {
var myswitch = UISwitch()
var showSwitch: Bool = true {
didSet { myswitch.isHidden = !showSwitch }
}
required init?(coder: NSCoder) { fatalError("Not implemented") }
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init( style: style, reuseIdentifier: reuseIdentifier )
setupInterface()
}
}
// MARK: - Public
extension SettingsCell {
}
// MARK: - Private
private extension SettingsCell {
func setupInterface() {
myswitch.isOn = false
myswitch.addTarget( self, action: #selector(onSwitch), for: .valueChanged )
addSubview( myswitch )
myswitch.translatesAutoresizingMaskIntoConstraints = false
myswitch.centerYAnchor.constraint( equalTo: centerYAnchor ).isActive = true
myswitch.rightAnchor.constraint( equalTo: rightAnchor, constant: -16 ).isActive = true
}
@objc func onSwitch( sender: UISwitch ) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment