2013-04-08 12 views
6

Come posso spostare una vista dal basso verso l'alto il mio codice:Moving UIView dal basso verso l'alto

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

Così come posso aggiungere l'animazione qui?

+0

Cosa hai provato? Quali ricerche hai fatto prima di fare questa domanda? – Sebivor

+0

potresti utilizzare CATransition sul livello di visualizzazione http://stackoverflow.com/a/23195924/1378447 –

risposta

51

Inizialmente, aggiungi la tua vista:

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

Per l'animazione dal basso verso l'alto aggiungere di seguito:

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

Per rimuovere la vista

[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]; 
         }]; 
+0

postStatus is ur view name ryt? – Naveen

+0

Sì, questo era il mio nome di vista @naveen – Vinodh

+0

nice..it ha funzionato –

1
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]; 
        }]; 
+2

Piuttosto che buttare fuori qualche codice, sarebbe molto più utile spiegare cosa si sta facendo e perché, –

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){ 

       }]; 
     }]; 
}]; 
Problemi correlati