CGAffineTransformMakeScale() distorting view frame after animation

痴心易碎 提交于 2019-12-11 03:58:42

问题


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];

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.

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.


回答1:


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


来源:https://stackoverflow.com/questions/24878268/cgaffinetransformmakescale-distorting-view-frame-after-animation

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