ormMakeTranslation与CGRectOffset动

ormMakeTranslation与CGRectOffset动

本文介绍了CGAffineTransformMakeTranslation与CGRectOffset动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知道这是有关我的问题,但我有一个移动的动画序列的的UIView 出具有以下code画幅的:

Not sure if this is relevant to my question, but I have an animation sequence that moves a UIView out of frame with the following code:

[UIView animateWithDuration:0.3
                      delay:0
                    options:UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     _popupView.transform = CGAffineTransformMakeTranslation(0, -750);
                 }
                 completion:^(BOOL finished) {
                     _popupView.alpha = 0.0f;
}];

我有previously一直用这个的而不是以上的动画

                 ....
                 animations:^{
                     _popupView.frame = CGRectOffset(_popupView.frame, 0, -750);
                 }

我一直在表演时得到了一些奇怪出问题误差 CGRectOffset 不管出于什么原因,但只要我取代移动与视图的方法 CGAffineTransfromMakeTranslation 毛刺似乎已经消失。

I had been getting some strange glitchy errors when performing the CGRectOffset for whatever reason, but as soon as I replaced the method of moving the view with the CGAffineTransfromMakeTranslation the glitch seems to have gone away.

我的问题是这样的:


  • 什么是最终的结果差异(如有的话)这两种方法之间
    动画(动)的对象的位置?

如果有,可以
   解释我正在经历在闪烁的观点的原因
   动画(在屏幕的下方,几乎就像是设定
   其帧在屏幕的底部)。如果这不是很清楚,我有一个单独的职位,要求更具体这个故障与我的CGRectOffset毛刺。

感谢您的帮助!

推荐答案

不同的是,自动布局预计将有你的观点的中心的完全控制权 bounds.size ,并根据在任意时间安装的限制它们复位。

The difference is that auto layout expects to have complete control of your view's center and bounds.size, and will reset them according to the installed constraints at arbitrary times.

自动布局小心(如iOS版8.0),以避免连看你的视图的变换。你变换对汽车布局中设置的框架的顶部被应用,和经销商的布局从来没有复位了。

Auto layout is careful (as of iOS 8.0) to avoid even looking at your view's transform. Your transform is applied on top of the frame set by auto layout, and auto layout never resets it.

所以,你可以使用你的视图的位置变换,或者通过更新约束动画。试图通过直接设置其帧动画的立场会导致意外的行为。

So, you can animate your view's position using the transform, or by updating its constraints. Trying to animate its position by setting its frame directly leads to unexpected behavior.

这篇关于CGAffineTransformMakeTranslation与CGRectOffset动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 09:38