2013-04-08 56 views
6

Làm thế nào tôi có thể di chuyển một cái nhìn từ dưới lên trên vào mã của tôi:Moving UIView từ dưới lên trên

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

Vậy làm thế nào tôi có thể thêm các hình ảnh động ở đây?

+0

Bạn đã thử những gì? Bạn đã thực hiện nghiên cứu nào trước khi đặt câu hỏi này? – Sebivor

+0

bạn có thể sử dụng CATransition trên lớp xem http://stackoverflow.com/a/23195924/1378447 –

Trả lời

51

Ban đầu, thêm quan điểm của bạn:

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

Đối với các hình ảnh động từ dưới lên trên thêm dưới đây:

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

Đối với loại bỏ quan điểm

[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 là ur view name ryt? – Naveen

+0

có tên của tôi là @naveen – Vinodh

+0

nice..it's work –

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

Thay vì chỉ ném một số mã, nó sẽ hữu ích hơn nhiều để giải thích những gì đang được thực hiện và tại sao, –

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

       }]; 
     }]; 
}];