当UIView高度设置为零时,视图的子控件不会隐藏

Mon*_*tel 5 animation objective-c uiview ios

我想抽屉动画.所以我拿了1个UIView并在UIView中添加了4个控件.现在当我点击抽屉按钮时,在抽屉关闭时设置视图高度为零,在抽屉打开时设置视图高度200.

但是当我设置零高度时,按钮不会隐藏.所有按钮都可见. 自动布局不在我的项目中.

如何解决这个问题.

-(IBAction)Onclick_drawer:(id)sender
{
    if(is_open)
    {
        is_open=false;
        [UIView animateWithDuration:0.3
                              delay:0.0
             usingSpringWithDamping:1.0
              initialSpringVelocity:4.0
                            options: UIViewAnimationOptionCurveEaseInOut
                         animations:^{

                             self.drawer_view.frame=CGRectMake(0, 64, 320,200);
                         }
                         completion:^(BOOL finished){

                         }];
        [UIView commitAnimations];
    }

    else
    {
        is_open=true;
        [UIView animateWithDuration:0.3
                              delay:0.0
             usingSpringWithDamping:1.0
              initialSpringVelocity:4.0
                            options: UIViewAnimationOptionCurveEaseInOut
                         animations:^{
                             self.drawer_view.frame=CGRectMake(0, 64, 320, 0);
                         }
                         completion:^(BOOL finished){

                         }];
        [UIView commitAnimations];
    }


}
Run Code Online (Sandbox Code Playgroud)

EI *_*2.0 12

签入xib ... select view -> attribute inspector -> check clip Subviews如下图所示

在此输入图像描述

或以编程方式使用

   self.yourview.clipsToBounds = YES;
Run Code Online (Sandbox Code Playgroud)