2017-12-03 37 views
0

전체 화면의 화면 중앙에있는 UIImageView 객체가 있습니다. 같은 코드에서 크기와 변환을 수행하는 애니메이션을 만들었습니다.swift - 화면 조정 좌표 wth 애니메이션에 UIImageView 번역

UIView.animate(withDuration: 1.0, animations: { 
     let originalTransform = self.idImageView.transform 
     let scaledTransform = originalTransform.scaledBy(x: 0.2, y: 0.2) 
     let scaledAndTranslatedTransform = scaledTransform.translatedBy(x: 100, y: 100) 
     self.idImageView.transform = scaledAndTranslatedTransform 
    }, completion: { (finished) in 
     self.animationCompeletedSuccessfully(finished) 
    }) 

내가 내 UIImageView에 이동이 조율하는 X = 100, Y = 100을 원하지만 그게에게이 센터에 100 점 상대적으로 이동 번역 : 여기에 소스 코드입니다. 창 좌표계에서 어떻게 변환 할 수 있습니까 ?? Apple Documentation of traslatedBy(x: , y:) 나는이 하나를 읽었지만의이 imageview 센터 x, y 좌표와 width, height을 가지고 있다고 가정 해 봅시다 공동 ordiante 시스템

답변

1

에 대해 명확하게 이해할 수 없었다 . 원하는 목적지 : destinationX,

destinationY

번역은 다음과 같습니다 X에 의해

  • : destinationY - y + height/2

당신이 규모를 할 경우 width과 기억 : 예에 의한 destinationX - x + width/2

  • height에 scaleRatio를 곱해야합니다.

  • +0

    답장을 보내 주셔서 감사합니다. 부분적으로 작동합니다. 나는 이유를 모른다. 예상 지점 근처에서 내 견해를 움직입니다. 그리고 나는 당신의 마지막 줄을 과장하지 않습니다. 설명해 주시겠습니까? –

    +0

    귀하의 경우 그것은'destinationX - x + width/2 * 0.2'이고'y'와 동일합니다 –

    +0

    코드를 편집하여 구현 한 다음 도와 드릴 수 있습니다 –