iphone - 使CGAffineTransform永久化 [英] iphone - making the CGAffineTransform permanent

查看:108
本文介绍了iphone - 使CGAffineTransform永久化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于这个问题,我正在敲打我的脑袋:

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

当我创建一个UIImageView时,这个视图有一定的方向和大小。让我们称这个状态为A。

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.

在代码中的某个时刻,我将CGAffineTransform应用于视图。如果仿射是规模,旋转,翻译或所有的组合,则无关紧要。如果变换是绝对的或相对的也无关紧要。更不用说设备可以改变它的方向,并且视图被自动旋转到正确的方向(我们可以认为cay是一种应用于视图的旋转或变换)。

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).

问题是:当我触摸该对象或尝试设置其透明度或任何其他参数的动画时,它会记住状态A并从该状态执行所有动画,而不是从当前状态执行。如果我只是触摸视图,它会立即返回状态A。代码本身并没有这样做。这很烦人。如何创建视图假设其当前的转换状态为重置或初始状态?换句话说,如何让视图忘记过去的转换或状态?

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?

谢谢

推荐答案

Afaik,所有SDK动画都会自动创建副本,在隐藏原件的同时在副本上执行动画。在你的代码中,你将有一个 getState 行,它会启动它并创建指向动画对象的指针。要在动画例程结束时使其永久化,请将原始对象视图设置为动画视图。

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就像这样,但我没有我的代码我面前的样品:

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.

这篇关于iphone - 使CGAffineTransform永久化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆