移动和缩放反弹

时间:2013-07-20 13:07:48

标签: ios objective-c uiviewanimation

正如您在this video中看到的那样,只要我尝试裁剪或移动裁剪框,它就会反弹。我找不到任何方法来做这件事,我认为我的代码是正确的。我怎么想这样做?

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.
  if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                          message:@"Device has no camera"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles: nil];
    [myAlertView show];
  }
}

- (IBAction)takePhoto:(UIButton *)sender {
  UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  picker.delegate = self;
  picker.allowsEditing = YES;
  picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  [self presentViewController:picker animated:YES completion:NULL];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
  self.imageView.image = chosenImage;
  [picker dismissViewControllerAnimated:YES completion:NULL];
}

1 个答案:

答案 0 :(得分:0)

如果图像太远,请使用此方法为其设置动画:

[UIView animateWithDuration: animations: completion:]

动画:是一个块,如果你想改变你添加的图像位置,它会在一段时间内改变,例如CGRect {/ 1}}

完成:是一个块但不是必需的。