I want drawer animation. So I take 1 UIView and add 4 control inside UIView. Now when I click on drawer button, set view height zero when drawer is close and set view height 200 when drawer is open.
But when I set zero height, button is not hide . All buttons are visible. Auto layout is not in my project.
How to solved this problem.?
-(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];
}
}
check in xib ... select view -> attribute inspector -> check clip Subviews
like below image
or programatically use
self.yourview.clipsToBounds = YES;
Just select the view and go to right side of screen into attribute inspector
Check the check box for Clip Subviews
-(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];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With