Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. let view = UIView(frame: self.view.bounds)
  2. self.view.addSubview(view)
  3.  
  4.  
  5. let circle = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width - 20, height: view.frame.width - 20))
  6. view.addSubview(circle)
  7. circle.center = view.center
  8. circle.layer.cornerRadius = circle.frame.height / 2
  9. circle.backgroundColor = UIColor.gray.withAlphaComponent(0.7)
  10.  
  11.  
  12.  
  13.  
  14. let dotView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
  15. dotView.layer.cornerRadius = dotView.frame.width / 2
  16. dotView.backgroundColor = UIColor.purple.withAlphaComponent(0.89)
  17. dotView.center = circle.center
  18. circle.addSubview(dotView)
  19.  
  20.  
  21. let location1 = CLLocation(latitude: 21.642534, longitude: 69.607003)
  22. let location2 = CLLocation(latitude: 21.642083, longitude: 69.614587)
  23.  
  24. let angleStep = CGFloat(location1.bearingRadianTo(location: location2))
  25. print(location1.bearingDegreesTo(location: location2))
  26. let xPos = cos(angleStep) * (circle.frame.width / 2)
  27. let yPos = sin(angleStep) * (circle.frame.width / 2)
  28.  
  29. dotView.center = CGPoint(x:circle.center.x + xPos - circle.frame.origin.x, y:circle.center.y + yPos - circle.frame.origin.y);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement