Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import UIKit
  2.  
  3. class ViewController: UIViewController {
  4.  
  5. var isBlue = true
  6.  
  7. @IBOutlet weak var greenView: UIView!
  8. @IBOutlet weak var blueView: UIView!
  9.  
  10. override func viewDidLoad() {
  11. super.viewDidLoad()
  12. }
  13.  
  14. @IBAction func changeBackgroundColorOnTap(_ sender: UITapGestureRecognizer) {
  15. let aquaColor = blueView.backgroundColor
  16.  
  17. if isBlue == true {
  18. blueView.backgroundColor = greenView.backgroundColor
  19. } else {
  20. blueView.backgroundColor = UIColor(red: 0/255.0, green: 128/255.0, blue: 255/255.0, alpha: 1)
  21. }
  22. isBlue = !isBlue
  23. }
  24. @IBAction func didBeginPanGesture(_ sender: UIPanGestureRecognizer) {
  25. let point = sender.location(in: view)
  26. greenView.center = CGPoint(x: point.x, y: point.y)
  27. }
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement