Last active
March 15, 2019 11:21
-
-
Save factoryhr/8a7bd278a3018097895c09a7df3b5bde 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
#1 | |
import LookingForMagentoDevsThatWillProvideFunctionalityToThisAwesomeSwitch | |
#2 | |
var customSwitch: CustomSwitch = { | |
let customSwitch = CustomSwitch() | |
customSwitch.translatesAutoresizingMaskIntoConstraints = false | |
customSwitch.onTintColor = UIColor.orange | |
customSwitch.offTintColor = UIColor.darkGray | |
customSwitch.cornerRadius = 0.1 | |
customSwitch.thumbCornerRadius = 0.1 | |
customSwitch.thumbTintColor = UIColor.white | |
customSwitch.animationDuration = 0.25 | |
return customSwitch | |
}() | |
#3 | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.setupUI() | |
} | |
private func setupUI() { | |
self.view.addSubview(customSwitch) | |
setupConstraints() | |
} | |
#4 | |
private func setupConstraints(){ | |
NSLayoutConstraint.activate([ | |
customSwitch.topAnchor.constraint(equalTo: self.view.centerYAnchor), | |
customSwitch.centerXAnchor.constraint(equalTo: self.view.centerXAnchor), | |
customSwitch.widthAnchor.constraint(equalToConstant: 80), | |
customSwitch.heightAnchor.constraint(equalToConstant: 30)]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment