カメラビューに丸い形を与えて画像を撮ろうとしています。円は幅 200、高さ 200 である必要があり、円が開いている場合でも、ユーザーは背景ビューを操作できる必要があります。これまでに管理したのは次のとおりです。
- (IBAction)useCameraPhoto:(id)sender
{
if ([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker =
[[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType =
UIImagePickerControllerSourceTypeCamera;
imagePicker.mediaTypes = [NSArray arrayWithObjects:
(NSString *) kUTTypeImage,
nil];
imagePicker.allowsEditing = YES;
[self presentViewController:imagePicker
animated:YES completion:nil];
newMedia = YES;
}else{
NSLog(@"Camera is not available");
UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Important message" message:@"Unfortunately the camera is not available on your device." delegate:self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
[alert1 show];
}
}
このコードは、ユーザーがショットを撮ることができるビューコントローラーを表示していますが、丸い形ではありません。
imagePicker.allowsEditing.frame = CGRectMake (30, 100, 200, 200); のようなことを考えました。それでも、これでは角が丸くなりません。さらに、その下のビューは、表示されていても、タッチに反応しません。何か案は?
編集:
私はこれを試しました。角は丸くなりますが、背景はまだ黒です
imagePicker.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
imagePicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:imagePicker animated:YES completion:nil];
imagePicker.view.layer.cornerRadius = 100; // this value vary as per your desire
imagePicker.view.clipsToBounds = YES;
imagePicker.view.frame = CGRectMake(40,40, 200, 200);