-1
UI에서 원을 삭제 한 다음 다른 곳에서 다시 생성하는 애니메이션이 있지만 다시 만들 때 원하는 것보다 작습니다. 나는 그것이 왜 더 작은 것처럼 보이는지 알 수 없다.Swift - 애니메이션 효과 삭제
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)
}
다른 모든 것들을 제거하려고 시도했지만 항상 작게 표시됩니다. 이 일이 왜 발생하는지에 대한 도움은 아주 좋습니다.
다음은 처음으로 createCircle()
이 어떻게 표시되는지 보여줍니다.
이이 애니메이션에서 호출 할 때 보이는 방법이다. CAAnimation가 원래 크기로 재설정됩니다, 그래서 내가 생각
이전과 이후의 사진을 업로드하는 데 어려움을 겪고 있었지만 여기에는 보관 용 계정 링크가 있습니다. 커다란 점이있는 것은 createCircle()이 처음으로 호출 된 모습이며 다른 그림은 애니메이션에서 호출 될 때의 모습입니다. https://www.dropbox.com/sh/bccvdfnrjgou2tp/AABZYmswSlwkXimAHG_dQ9tYa?dl=0 – Taylor
removeAllAnimations 및 removeFromSuperview를 수정하여 문제를 해결할 수 있었는지 확인했습니다. 내가 아는 한 createCircle()은 매번 그것을 생성하지 않는다. variable circle은 viewController의 모든 함수 외부에서 호출되므로 다른 함수에서 해당 변수를 편집 할 수 있습니다. 내가 그들을 재창조 할 때마다, 나는 이전에 있었던 것들로부터 편집되고 있다고 생각한다. – Taylor
수정 방법은 무엇입니까? – Taylor