CGAffineTransformMakeScale()在动画后扭曲视图帧 [英] CGAffineTransformMakeScale() distorting view frame after animation

查看:260
本文介绍了CGAffineTransformMakeScale()在动画后扭曲视图帧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我动画的视图,使其显示,因为它是从屏幕的一个theCGAffineTransformMakeScale()的中心生长,它工作正常在iOS的8个β4模拟器,但是,从7.1版本它扭曲的帧查看。

I'm animating a view to make it appear as it is growing from the center of the screen with a theCGAffineTransformMakeScale(), it works fine in the iOS 8 beta 4 simulator but on the 7.1 version it distorts the frame of the view.

view.alpha     = 0.0f;
view.transform = CGAffineTransformMakeScale(0.95f, 0.95f);

[UIView animateWithDuration:0.5f
                      delay:0.0f
     usingSpringWithDamping:1.0f
      initialSpringVelocity:1
                    options:0
                 animations:^{
                    view.alpha     = 1.0f;
                    view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
                             }
                 completion:nil];

在iOS 8和iOS 7.1版本的上一次测试版中,它运行良好。
其他有这个问题的人,视图是一个UINavigationControl表。

And it worked well in the last beta in both the iOS 8 and iOS 7.1 versions. Anyone else having this problem, the view is a table of a UINavigationControl.

做一些测试似乎变换是拉伸视图帧而不是缩放它在动画期间。

Doing some tests it seems the transform is stretching the views frame instead of scaling it during the animation.

经过进一步测试,我发现只有使视图变小(例如1.0到0.9)的变换才会导致它改变宽度,如果变换使视图更大(1.1到1.0),然后将其动画为当前正常比例,动画执行没有问题。

Upon further testing i found out that only transforms that makes the view smaller(1.0 to 0.9 for example) cause it to change its width, if the transform makes the view bigger (1.1 to 1.0) and then animates it to its current normal scale, the animation performs without problems.

推荐答案

当转换的起点或终点具有零刻度时,有时会出现失真。尝试将初始变换设置为小但非零,例如。

You can sometimes get distortion when either the start or endpoint of the transformation has zero scale. Try setting your initial transform to something small but nonzero, e.g.

view.transform = CGAffineTransformMakeScale(0.01f, 0.01f);

这篇关于CGAffineTransformMakeScale()在动画后扭曲视图帧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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