6

如何在我的代码上从下到上移动视图:

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

那么如何在这里添加动画呢?

4

3 回答 3

55

最初,添加您的视图:

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

对于从下到上的动画,请添加以下内容:

[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];

用于移除视图

[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];
                         }];
于 2013-04-08T04:53:47.767 回答
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];
                     }];
于 2015-03-21T04:56:54.417 回答
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){

                }];
        }];
 }];
于 2016-08-31T07:46:45.913 回答