Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let view = UIView(frame: self.view.bounds)
- self.view.addSubview(view)
- let circle = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.width - 20, height: view.frame.width - 20))
- view.addSubview(circle)
- circle.center = view.center
- circle.layer.cornerRadius = circle.frame.height / 2
- circle.backgroundColor = UIColor.gray.withAlphaComponent(0.7)
- let dotView = UIView(frame: CGRect(x: 0, y: 0, width: 10, height: 10))
- dotView.layer.cornerRadius = dotView.frame.width / 2
- dotView.backgroundColor = UIColor.purple.withAlphaComponent(0.89)
- dotView.center = circle.center
- circle.addSubview(dotView)
- let location1 = CLLocation(latitude: 21.642534, longitude: 69.607003)
- let location2 = CLLocation(latitude: 21.642083, longitude: 69.614587)
- let angleStep = CGFloat(location1.bearingRadianTo(location: location2))
- print(location1.bearingDegreesTo(location: location2))
- let xPos = cos(angleStep) * (circle.frame.width / 2)
- let yPos = sin(angleStep) * (circle.frame.width / 2)
- 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