图像掉落动画

时间:2015-10-23 22:12:03

标签: ios objective-c

我已经实现了一个取消按钮,它可以清除拍摄的图像并将其指定为零。但是,当用户点击取消按钮时,我想实现动画,拍摄的图像会掉落并离开屏幕。

我怎么能够实现它?

- (void)imagePickerController:(UIImagePickerController *)picker
 didFinishPickingMediaWithInfo:(NSDictionary *)info {

   UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    selectPhotoBtnOutlet.hidden=YES;
    takePhotoBtnOutlet.hidden=YES;
    __block PhotosViewController *aBlockSelf = self; 
    [picker dismissViewControllerAnimated:YES completion:^{
        aBlockSelf.productImg.hidden = NO;
        aBlockSelf.makeTF.hidden = NO;
        aBlockSelf.cancelBtnOutlet.hidden=NO;
        aBlockSelf.productImg.image = chosenImage;
    }];
 }


- (IBAction)cnclBtnClick:(id)sender {
    self.productImg.image = nil;
    self.cancelBtnOutlet.hidden=YES;
}

1 个答案:

答案 0 :(得分:0)

您可以使用此animateWithDuration完成块删除视图

[UIView animateWithDuration:0.2
                 animations:^{
                     [self.productImg setFrame:CGRectMake(0, self.view.frame.size.height, self.productImg.frame.size.width, self.productImg.frame.size.height)]; //this is moving the y of the self.productImg down
                 } completion:^(BOOL finished) {
                     [self.productImg removeFromSuperview];
                     self.productImg.image = nil;
                     self.cancelBtnOutlet.hidden=YES;
                 }];