I have an animation that deletes a circle in the UI and then recreates it somewhere else, but when I recreate it, it is smaller than what I want. I can't figure out why it is appearing smaller.
let viewsToAnimate = [circleFrame]
UIView.perform(UISystemAnimation.delete, on: viewsToAnimate, options: [], animations: {
}, completion: { finished in
self.circle.removeFromSuperlayer()
self.circleFrame.removeFromSuperview()
self.circleFrame.layer.removeAllAnimations()
self.createCircle()
self.score = self.score + 1
self.scoreLabel.text = "Taps: " + String(self.score)
self.tapsLabel.text = "Taps: " + String(self.initialTaps + self.score)
})
func createCircle() {
let randomX = generateRandomX()
let randomY = generateRandomY()
circleCenter = generateCircleCenter(x: randomX, y: randomY)
circleFrame.frame = CGRect(x: randomX, y: randomY, width: 100, height: 100)
circleFrame.alpha = 1.0
self.view.addSubview(circleFrame)
circle.path = UIBezierPath(roundedRect: CGRect(x: 0, y: 0, width: 100, height: 100), cornerRadius: 50).cgPath
circle.fillColor = UIColor(red: 0, green: greenValue/255, blue: 0.6, alpha: 1.0).cgColor
circle.strokeColor = UIColor(red: 1, green: greenValue/255, blue: 0, alpha: 1.0).cgColor
circle.lineWidth = 0
circleFrame.layer.addSublayer(circle)
}
I have tried removing all the animations among other things but it always appears smaller. Any help on why this happens would be great.
Here is how it looks the first time createCircle()
is called.
This is how it looks when it is called from the animation.