6

How can I move a view from bottom to top on my code:

colorView.hidden=NO;
colorView=[[UIView alloc]init];
colorView.frame=CGRectMake(0,480,320, 480);
colorView.bounds=CGRectMake(0,200,320, 280);
colorView.backgroundColor=[UIColor greenColor];
colorView.alpha=1.0f;
[webView addSubview:colorView];
[self.view addSubview:webView];
[self createTransparentView];

So how can I add the animation here?

Stanislav Pankevich
  • 11,044
  • 8
  • 69
  • 129
Naveen
  • 1,251
  • 9
  • 20
  • 38

3 Answers3

55

Initially, add your view:

self.postStatusView.frame = CGRectMake(0, 490, 320, 460);

For the animation from bottom to top add below:

[UIView animateWithDuration:0.5
                      delay:0.1
                    options: UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     self.postStatusView.frame = CGRectMake(0, 0, 320, 460);
                 } 
                 completion:^(BOOL finished){
                 }];
[self.view addSubview:self.postStatusView];

For removing the view

[UIView animateWithDuration:1.5
                              delay:0.5
                            options: UIViewAnimationOptionCurveEaseIn
                         animations:^{
    self.postStatusView.frame = CGRectMake(0, 490, 320, 460);
                         }
                         completion:^(BOOL finished){
                             if (finished)
                                 [self.postStatusView removeFromSuperview];
                         }];
Itai Spector
  • 652
  • 11
  • 24
Vinodh
  • 5,262
  • 4
  • 38
  • 68
3
self.colorView.frame = CGRectMake(0, 490, 320, 460);

[UIView animateWithDuration:0.5
                 delay:0.1
                options: UIViewAnimationCurveEaseIn
             animations:^{
                 self.colorView.frame = CGRectMake(0, 0, 320, 460);
             } 
             completion:^(BOOL finished){
             }];
[self.view addSubview:self.colorView];

[UIView animateWithDuration:1.5
                          delay:0.5
                        options: UIViewAnimationCurveEaseIn
                     animations:^{
self.colorView.frame = CGRectMake(0, 490, 320, 460);
                     }
                     completion:^(BOOL finished){
                             [self.colorView removeFromSuperview];
                     }];
Nazik
  • 8,696
  • 27
  • 77
  • 123
Waqas Ali
  • 51
  • 5
0
self.tableView.frame = CGRectMake(0, 490, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);

[UIView animateWithDuration:.35
                      delay:0.0
                    options:  UIViewAnimationOptionCurveEaseInOut
                 animations:^{
                     self.tableView.frame = CGRectMake(0, -20, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);
                 }
                 completion:^(BOOL finished){
                     [UIView animateWithDuration:0.1   delay:0.0
                      options:  UIViewAnimationOptionCurveEaseInOut   animations:^{

                         self.tableView.frame = CGRectMake(0, 20, [[UIScreen mainScreen] bounds].size.width , [[UIScreen mainScreen] bounds].size.height);

                     } completion:^(BOOL finished){

                         [UIView animateWithDuration:0.1   delay:0.0
                          options:  UIViewAnimationOptionCurveEaseInOut animations:^{

                              self.tableView.frame = CGRectMake(0, 0, [[UIScreen mainScreen] bounds].size.width, [[UIScreen mainScreen] bounds].size.height);

                         } completion:^(BOOL finished){

                }];
        }];
 }];
alitosuner
  • 984
  • 1
  • 10
  • 15