I'm creating a dynamic animation system(UIKit Dynamics) with an object orbiting around a point (the center of the orbit). Radial gravity and Vortex, 2 simultaneous forces make the blue object orbit around the yellow object. They are UIFieldBehavior both.
lazy var animator: UIDynamicAnimator = {
return UIDynamicAnimator(referenceView: self.view)
}()
lazy var center: CGPoint = {
return CGPoint(x: self.view.frame.midX, y: self.view.frame.midY)
}()
lazy var radialGravity: UIFieldBehavior = {
let radialGravity: UIFieldBehavior = UIFieldBehavior.radialGravityField(position: self.center)
radialGravity.region = UIRegion(radius: 300.0)
radialGravity.strength = 1.5
radialGravity.falloff = 4.0
radialGravity.minimumRadius = 50.0
return radialGravity
}()
lazy var vortex: UIFieldBehavior = {
let vortex: UIFieldBehavior = UIFieldBehavior.vortexField()
vortex.position = self.center
vortex.region = UIRegion(radius: 200.0)
vortex.strength = 0.005
return vortex
}()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
animator.setValue(true, forKey: "debugEnabled")
let itemBehavior = UIDynamicItemBehavior(items: [orbitingView])
itemBehavior.density = 0.5
animator.addBehavior(itemBehavior)
vortex.addItem(orbitingView)
radialGravity.addItem(orbitingView)
animator.addBehavior(radialGravity)
animator.addBehavior(vortex)
}
I'm using the property observer to change the view layer properties and render a blue circle. And view's background blue border line is still there. How to remove it so there'll be only the circle?
@IBOutlet weak var orbitingView: UIView! {
willSet {
newValue.layer.cornerRadius = newValue.frame.width / 2.0
newValue.layer.borderWidth = 0.0
newValue.layer.backgroundColor = UIColor.blue.cgColor
}
}