1
我希望能夠用動畫將我的playerOne移動到point2,但當它移動時,它會從playerOne的左上角移動到point2的左上角。我想知道是否有一種方法可以將playerOne從中間而不是從左上角移到point2的中間。從中間而不是左上移動
@IBAction func moveToPoint2(_ sender: Any) {
playerOnePosition = 2
UIView.animate(withDuration: 1.25, delay: 0, options: .curveLinear, animations: {
self.playerOne.frame.origin.x = self.point2.frame.origin.x-self.playerOne.frame.height/2
}, completion: nil)
pickQuestion()
}
謝謝!完全忘記了中心價值! – Username
很高興幫助 –