我已经实现了一个取消按钮,它可以清除拍摄的图像并将其指定为零。但是,当用户点击取消按钮时,我想实现动画,拍摄的图像会掉落并离开屏幕。
我怎么能够实现它?
- (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;
}
答案 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;
}];