J'utilise un outil de reconnaissance de mouvement rotatif pour faire pivoter un UIView. Après avoir fait pivoter la vue, les coordonnées x et y du mouvement de panoramique sont hors de leur axe et je ne vois pas pourquoi.Problème de rotation rapide x et y hors axe
Voici ma configuration actuelle geste:
open func handleRotate(sender: UIRotationGestureRecognizer) {
if sender.state == .began || sender.state == .changed {
sender.view?.transform = (sender.view?.transform)!.rotated(by: sender.rotation)
sender.rotation = 0
}
}
@objc fileprivate func handleDrag(sender: UIPanGestureRecognizer) {
let translation = sender.translation(in: self)
sender.view!.center = CGPoint(x: sender.view!.center.x + translation.x, y: sender.view!.center.y + translation.y)
sender.setTranslation(.zero, in: self)
}
Alors, quand je tourne la UIView x et balayage panoramique y sont impures (Progresser déplace le UIView à gauche ou à droite en fonction de l'état rotation de UIView).
Merci
essayer le réglage du point de vue d'ancrage avant de faire la rotation ... essayez ceci 'view.layer. anchorPoint = CGPoint.init (x: 0.5, y: 0.5) ' ' – Bilal
Cela n'a pas fonctionné @Bilal – user7684436