2016-03-23 7 views
1

引き出しアニメーションが必要です。だから私は1 UIViewを取ると4つのコントロールをUIViewの中に追加します。 引き出しボタンをクリックすると、引き出しが閉じているときに表示の高さをゼロに設定し、引き出しが開いているときに表示の高さ200を設定します。UIViewの高さを0に設定すると、ビューの子コントロールが非表示にならない

しかし、高さをゼロに設定すると、ボタンは非表示になりません。すべてのボタンが表示されます。 プロジェクトに自動レイアウトがありません。

この問題を解決するには?

-(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]; 
    } 


} 
+0

おかげ@EIキャプテン 私の問題が解決される使用。 TYSM –

答えて

5

チェックのためのチェックボックスをオンにします。.. select view -> attribute inspector -> check clip Subviews以下の画像

enter image description here

またはプログラム的

self.yourview.clipsToBounds = YES; 
+0

あなたは私の一日を救った! <3 @ –

+0

@ David'mArm'Ansermotそれは助けてうれしい:) –

1
-(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); 
          self.drawer_view.clipsToBounds = YES; // Need to add this line. This will clip all sub views into parent view 
         } 
         completion:^(BOOL finished){ 

         }]; 
     [UIView commitAnimations]; 
    } 


} 
2

だけでビューを選択し、属性インスペクタに、画面の右側に

を行くXIBでClip Subviews

enter image description here

関連する問題