Created
January 8, 2021 22:21
-
-
Save exorcyze/f1dace7d4988650bda7b326d27af83ed to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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