iphone - making the CGAffineTransform permanent

半腔热情 提交于 2019-12-10 11:49:23

问题


I am banging my head on the wall here due to this problem:

When I create a UIImageView this view has a certain orientation and size. Lets call this state "A".

This view responds to taps. It can be dragged around the screen.

At some point in the code I apply a CGAffineTransform to the view. Does not matter if the affine is a scale, a rotation, a translation or a combination of all. Does not matter also if the transform is absolute or relative. Not to mention the device can change its orientation and the view is autorotated to the correct orientation (that we can cay is a kind of rotation or transformation applied to the view).

The problem is: the moment I touch that object or try to animate its transparency or any other parameter, it "remembers" the state "A" and does all animations from that state, not from current state. If I simply touch the view, it returns instantly to state "A". The code is not doing it by itself. It is pretty annoying. How to I make a view assume its current state of transformations as the reset or initial state? In other words, how do I make a view forget its past transformations or states?

The only way I know is recreating the view, but this is a ridiculous way of doing this.

Is there any way to make this work as I described?

thanks


回答1:


Afaik, all of the SDK animations automatically create a copy, perform the animation on the copy while hiding the original. In your code you'll have a getState line that starts this and creates the pointer to the animation object. To make it permanent at the end of your animation routine set the original objects view to the animation view.

Iirc it something like this, but I don't have my code samples in front of me:

myOriginalObject.view = myMnimationObject.view

Obviously do this before you release your animations but after you're done with the transforms.



来源:https://stackoverflow.com/questions/2703171/iphone-making-the-cgaffinetransform-permanent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!