Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. #1
  2. import LookingForMagentoDevsThatWillProvideFunctionalityToThisAwesomeSwitch
  3. #2
  4. var customSwitch: CustomSwitch = {
  5. let customSwitch = CustomSwitch()
  6. customSwitch.translatesAutoresizingMaskIntoConstraints = false
  7. customSwitch.onTintColor = UIColor.orange
  8. customSwitch.offTintColor = UIColor.darkGray
  9. customSwitch.cornerRadius = 0.1
  10. customSwitch.thumbCornerRadius = 0.1
  11. customSwitch.thumbTintColor = UIColor.white
  12. customSwitch.animationDuration = 0.25
  13. return customSwitch
  14. }()
  15. #3
  16. override func viewDidLoad() {
  17. super.viewDidLoad()
  18. self.setupUI()
  19. }
  20.  
  21. private func setupUI() {
  22. self.view.addSubview(customSwitch)
  23. setupConstraints()
  24. }
  25. #4
  26. private func setupConstraints(){
  27. NSLayoutConstraint.activate([
  28. customSwitch.topAnchor.constraint(equalTo: self.view.centerYAnchor),
  29. customSwitch.centerXAnchor.constraint(equalTo: self.view.centerXAnchor),
  30. customSwitch.widthAnchor.constraint(equalToConstant: 80),
  31. customSwitch.heightAnchor.constraint(equalToConstant: 30)])
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement