Animate Custom UIView:
First Define in header file: .h
UIView * animatedView;
@property (assign) IBOutlet UIView * animatedView;
and Two Actions
- (IBAction) btnOpenViewM;
- (IBAction) btnCloseViewM;
And then Define logic in Implementation View .m file
First Time Show the suddenly disappear
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
//======== Animate Bar =======================
CGRect anBarFrame = animatedView.frame;
anBarFrame.origin.x = -anBarFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.9];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
animatedView.frame = anBarFrame;
[UIView commitAnimations];
btnOpenView.hidden = NO;
btnCloseView.hidden = YES;
}
Now Show on Button
//======= Animate Bar ==================
- (IBAction) btnOpenViewM
{
btnOpenView.hidden = YES;
btnCloseView.hidden = NO;
CGRect anBarFrame = animatedView.frame;
anBarFrame.origin.x = anBarFrame.size.width - anBarFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
animatedView.frame = anBarFrame;
[UIView commitAnimations];
}
- (IBAction) btnCloseViewM
{
CGRect anBarFrame = animatedView.frame;
anBarFrame.origin.x = -anBarFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
animatedView.frame = anBarFrame;
[UIView commitAnimations];
btnOpenView.hidden = NO;
btnCloseView.hidden = YES;
}
First Define in header file: .h
UIView * animatedView;
@property (assign) IBOutlet UIView * animatedView;
and Two Actions
- (IBAction) btnOpenViewM;
- (IBAction) btnCloseViewM;
And then Define logic in Implementation View .m file
First Time Show the suddenly disappear
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:YES];
//======== Animate Bar =======================
CGRect anBarFrame = animatedView.frame;
anBarFrame.origin.x = -anBarFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.9];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
animatedView.frame = anBarFrame;
[UIView commitAnimations];
btnOpenView.hidden = NO;
btnCloseView.hidden = YES;
}
Now Show on Button
//======= Animate Bar ==================
- (IBAction) btnOpenViewM
{
btnOpenView.hidden = YES;
btnCloseView.hidden = NO;
CGRect anBarFrame = animatedView.frame;
anBarFrame.origin.x = anBarFrame.size.width - anBarFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
animatedView.frame = anBarFrame;
[UIView commitAnimations];
}
- (IBAction) btnCloseViewM
{
CGRect anBarFrame = animatedView.frame;
anBarFrame.origin.x = -anBarFrame.size.width;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:0.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
animatedView.frame = anBarFrame;
[UIView commitAnimations];
btnOpenView.hidden = NO;
btnCloseView.hidden = YES;
}
No comments:
Post a Comment