UIView从下到上依次出现,反之亦然(核心动画) [英] UIView appereance from bottom to top and vice versa(Core Animation)

查看:304
本文介绍了UIView从下到上依次出现,反之亦然(核心动画)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是通过核心动画来理解和实现功能。

我认为它不是那么难,但不幸的是我不知道swift / Obj C并且很难理解本机示例。

My goal is to understand and implement feature via Core Animation.
I think it's not so hard,but unfortunately i don't know swift/Obj C and it's hard to understand native examples.

那么究竟我想做什么(图片上显示的步骤很少):

1.

2.

3.

4.

So what exactly i want to do(few steps as shown on images):
1.
2.
3.
4.

和隐藏视图相同的步骤(反之亦然,从上到下)直到这个:

And the same steps to hide view(vice versa,from top to bottom) until this :

此外,我想制作这个 UIView 更通用,我的意思是将这个 UIView 放在我的StoryBoard上并对AutoLayout施加约束(以支持不同的设备屏幕)。

Also,i want to make this UIView more generic,i mean to put this UIView on my StoryBoard and put so constraints on AutoLayout(to support different device screens).

任何想法?谢谢!

推荐答案

假设原始视图类似于:

var view = new UIView(new CGRect(View.Frame.Left, View.Frame.Height - 200, View.Frame.Right, 0));
view.BackgroundColor = UIColor.Clear;



显示:



Show:

UIView.Animate(2.0, 0.0,
    UIViewAnimationOptions.CurveLinear,
    () =>
        {
            view.BackgroundColor = UIColor.Blue;
            var height = 100;
            view.Frame = new CGRect(View.Frame.Left, view.Frame.Y - height , view.Superview.Frame.Right, height);
        },
    () =>
        {
            // anim done
        }                                  
);



隐藏:



Hide:

UIView.Animate(2.0, 0.0,
    UIViewAnimationOptions.CurveLinear,
    () =>
        {
            view.BackgroundColor = UIColor.Clear;
            var height = 100;
            view.Frame = new CGRect(View.Frame.Left, view.Frame.Y + height, view.Superview.Frame.Right, 0);

        },
    () =>
        {
            view.Hidden = true;
        }
);

这篇关于UIView从下到上依次出现,反之亦然(核心动画)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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