Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #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)])
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement