A planetary animated UI with intractable planets in their respective orbits in swift.
public struct SolarConfiguration {
let planetsCount: Int
let orbitColor: UIColor
let orbitDistance: CGFloat
let planets: [Planet]? = nil
}
public protocol SolarViewDelegate: AnyObject {
func didBeginTouchPlanet(planet: Planet)
func didMovingPlanet(planet: Planet)
func didFinishTouchPlanet(planet: Planet)
}
struct PlanetConfig {
let id: String
let radius: CGFloat
let arcRadius: CGFloat
let arcCenter: CGPoint
let revolutionSpeed: CGFloat
let orbitPath: UIBezierPath
let isClockwise: Bool
let color: UIColor
}
func createSolarSystem() {
let config = SolarConfiguration(planetsCount: 8, orbitColor: .systemBlue, orbitDistance: 25)
let solarView = SolarView(frame: CGRect(x: 0.0, y: 0.0, width: self.view.frame.width, height: self.view.frame.width), configuration: config)
solarView.center = self.view.center
solarView.delegate = self
solarView.backgroundColor = .black
self.solarView = solarView
self.view.addSubview(solarView)
}
self.solarView.destroy()