从底部动画UIView的高度顶部 [英] Animate UIView height from bottom to top

查看:179
本文介绍了从底部动画UIView的高度顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做的UIView高度的一个简单的动画,这样它揭示。

I'm doing a simple animation of UIView height so that it reveals.

在默认情况下它似乎上下透出了,我希望它揭示底部顶部。

By default it seems to be revealing from top to bottom, and I want it to reveal bottom to top.

我有锚定在屏幕的底部的UIView

I have the UIView anchored to the bottom of the screen.

我敢肯定,这一些简单的我失踪.....任何提示?

I'm sure it something simple i'm missing..... any tips?

感谢

推荐答案

就像用骨头狗我想通了这一点......

Like a dog with a bone I figured this out....

相反动画帧的高度,我不是应用转换到视图,并设置图层的锚点。

Instead of animating the frame height, I instead apply a transform to the view and set the anchor point of the layer.

//set the anchor point to the bottom of the view
[self setAnchorPoint:CGPointMake(0.5, 1.0) forView:hostView];
//Scale the height to close to zero
hostView.transform = CGAffineTransformMakeScale(1, 0.00001);

如果我把0作为y缩放比例,认为行为怪异....在动画结束时,我只是将它设置为隐藏。

If I put 0 as the y scale, the view behaves weird.... at the end of the animation i just set it to hidden.

在回来的路上了,我只是使用身份变换(重置)

On the way back up I just use the Identity Transform (reset it)

hostView.transform = CGAffineTransformIdentity;

请注意改变自己的定位点转移我的看法的立场。看到这个帖子为其设置后正常化视图的setAnchorPoint方法anchorPoint

Note that changing my anchor point shifted the position of my view. See this post for the setAnchorPoint method which normalises the view after setting the anchorPoint

<一个href=\"http://stackoverflow.com/questions/1968017/changing-my-calayers-anchorpoint-moves-the-view\">Changing我的CALayer的anchorPoint移动视图

这篇关于从底部动画UIView的高度顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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