我在相机上做了动画,一切正常。 我可以启动相机,以叠加方式移动图像,并将其另存为图片。
我的问题是在“预览”中动画继续移动,我不知道相机何时进入此模式。我不知道如何检查布尔或做一些可以阻止叠加的事情。
有没有办法预览?或者是否存在一些显示相机状态的功能?
感谢您的时间。
// camera declaration
{
UIImagePickerController *imagePicker;
imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.delegate = self;
imagePicker.showsCameraControls = YES;
imagePicker.navigationBarHidden = YES;
imagePicker.toolbarHidden = YES;
imagePicker.cameraOverlayView = overlayView;
[self presentModalViewController:imagePicker animated:YES];
[self.view bringSubviewToFront:overlayView];
}
// animation
UIImageView *ani1;
ani1 = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ani1.png"]] autorelease];
[self.overlayView addSubview:ani1];
// loop for animation
[NSTimer scheduledTimerWithTimeInterval:0.05f target:self selector:@selector(loop) userInfo:nil repeats:YES];
-(void)loop {
// move x y each loop
newFrame = CGRectMake(x, y, 320, 480);
[ani1 setFrame:newFrame];
}
// camera finish
// take photo + overlay and save it
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo
{
imagePicker.showsCameraControls = NO;
[self presentModalViewController:imagePicker animated:NO];
[self.view bringSubviewToFront:overlayView];
UIGraphicsBeginImageContext(picker.view.bounds.size);
[picker.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *newImage;
newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
}
答案 0 :(得分:0)
您必须创建一个按钮,而不是使用Apple的默认按钮和UIImagePickerController的功能。