확실하지 않음 (그것은 다시 추적 같은 것 1+2+3+4
은 1
으로 시작하여 10
- 으로 끝났음을 알고 있습니다. *).
그런 경우 제 제안은 CGAffineTransform
에서 파생되어 원하는 값을 저장하는 것이지만 구조적이므로 그렇게 할 수 없으므로 제 생각에는 최선의 선택은 다음과 같은 래퍼 클래스를 작성하는 것입니다.
당신은이 접근법은 한계가없는거야 볼 수 있지만, 당신이 항상 모든 정도 적용
MyTransform
의 한 인스턴스를 사용할 수 있습니다
//do Your stuff
MyTransform t = new MyTransform();
t.Rotate(angle);
view.Transform = t;
//get the rotation
float r = t.Rotation;
//unfortunately You won't be able to do this:
float r2 = view.Transform.Rotation;
:
class MyTransform
{
//wrapped transform structure
private CGAffineTransform transform;
//stored info about rotation
public float Rotation { get; private set; }
public MyTransform()
{
transform = CGAffineTransform.MakeIdentity();
Rotation = 0;
}
public void Rotate(float angle)
{
//rotate the actual transform
transform.Rotate(angle);
//store the info about rotation
Rotation += angle;
}
//lets You expose the wrapped transform more conveniently
public static implicit operator CGAffineTransform(MyTransform mt)
{
return mt.transform;
}
}
이제 정의 된 연산자를 사용하면 다음과 같이이 클래스를 사용할 수 있습니다 변환의 rts 및 그 어딘가에 인스턴스를 저장할 수 있습니다 (또는, 아마도 그러한 변환의 모음).
또한 또는 이 MyTransform
클래스 번역 규모와 같은 다른 변환/저장 노출 할 수 있습니다,하지만 당신은 여기에서 갈 곳을 알 수 믿습니다.
* 는 정확히 내가 지금 갈거야 내가
당신의 접근 방식은 고체 틀렸다면 정정 해줘 주시기합니다. 하지만 누군가가 빛을 비추는 빛이 있다면 그 느낌은 자유 롭다! – LampShade