UIView appereance from bottom to top and vice versa(Core Animation)

前端 未结 4 1301
予麋鹿
予麋鹿 2021-02-02 12:24

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

4条回答
  •  误落风尘
    2021-02-02 13:09

    Assuming the original view is something like:

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

提交回复
热议问题