2
我想給圓形的相機視圖拍攝圖像。圓應該是200寬和200高,並且當它打開時,用戶必須仍然能夠與背景視圖交互。所有我現在已經到管理的是:相機控制器的自定義形狀IOS
- (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];
}
}
此代碼是從呈現,用戶可以採取了一槍一viewcontrller,但它不具有圓形。
我想過要做點像 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);