I am implementing SlideView animation which will slide from top or bottom depending on the configuration.
For the slideFromTop it works perfectly fine. For slideFromBottom it only shows half of the slide view. Here is my SlideViewController.
const int VIEW_HEIGHT = 44;
-(void) slideInFromBottom
{
CGRect screenSize = [[UIScreen mainScreen] bounds];
self.view.frame = CGRectMake(0,screenSize.size.height, self.view.frame.size.width, VIEW_HEIGHT);
[UIView animateWithDuration:2.0 animations:^{
self.view.frame = CGRectMake(0, screenSize.size.height - VIEW_HEIGHT, self.view.frame.size.width,VIEW_HEIGHT);
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
self.view.frame = CGRectMake(0, screenSize.size.height, self.view.frame.size.width, VIEW_HEIGHT);
} completion:^(BOOL finished) {
}];
}];
}
-(void) slideInFromTop
{
self.view.frame = CGRectMake(0, (-1) * VIEW_HEIGHT, self.view.frame.size.width, VIEW_HEIGHT);
CGRect temp = self.view.frame;
[UIView animateWithDuration:2.0 animations:^{
self.view.frame = CGRectMake(0, 0, self.view.frame.size.width,VIEW_HEIGHT);
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 delay:2.0 options:UIViewAnimationOptionAllowAnimatedContent animations:^{
self.view.frame = temp;
} completion:^(BOOL finished) {
}];
}];
}
The user calls the SlideViewController using the following code:
-(IBAction) save:(id) sender
{
SlideViewController *slideViewController = [[SlideViewController alloc] initWithTitle:@"Customer has been saved!" animationType:SlideInFromTop];
[self.view addSubview:slideViewController.view];
}
UPDATE 2:
self.view.frame = CGRectMake(0, screenSize.size.height - (1.3 * VIEW_HEIGHT), self.view.frame.size.width,VIEW_HEIGHT);
Save yourself some trouble and just download and install FTUtils
Just drop the project into yours, include the header, then you can do the animation in one line:
It has over a dozen very useful animations like the “pop in” effect on UIAlertViews. I litteraly use it all the time.