UIView 外观自下而上,反之亦然(核心动画) [英] UIView appereance from bottom to top and vice versa(Core Animation)

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

问题描述

我的目标是通过 Core Animation 理解和实现功能.
我认为这并不难,但不幸的是我不知道 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;

显示:

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

隐藏:

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天全站免登陆