我正在嘗試使用現場相機繪製應用程序。在那裏,我創建了一個名爲PaintView
的類,其中所有與繪畫相關的功能都在運行。如何使用相機覆蓋視圖在實時相機上繪圖:代碼中的問題
我加入paintview
到cameraoverlay
視圖。該視圖已正確添加。但是,當我觸摸設備的屏幕,應用程序不能畫任何東西,和日誌顯示以下錯誤
<錯誤>:CGContextSetLineWidth:無效的情況下0x11b540
<錯誤>:CGContextSetRGBStrokeColor:無效的上下文0x11b540
我的用於添加子視圖代碼是
// Insert the overlay
overlay = [[PaintView alloc] initWithNibName:@"PaintView" bundle:nil];
//overlay.pickerReference = self.imagePicker;
[self.imagePicker.cameraOverlayView addSubview:overlay.view];
[self.imagePicker.cameraOverlayView bringSubviewToFront:overlay.view];
[self.imagePicker.cameraOverlayView setBackgroundColor:[UIColor clearColor]];
//self.imagePicker.delegate = overlay;
[self presentModalViewController:self.imagePicker animated:YES];
請幫助我,如何在現場攝像機上畫畫!
在此先感謝。
EDIT:油漆視圖我創建圖像視圖,其像
初始化的drawImage = [[ALLOC的UIImageView] INIT];
drawImage.frame = CGRectMake(20,20,320,440);
[self.view addSubview:的drawImage];
[self.view bringSubviewToFront:的drawImage];
您是否正在繪製drawRect:PaintView方法? – rdelmar
是的,我正在繪製drawRect:方法,下面是代碼 –
drawImage = [[UIImageView alloc] initWithImage:nil]; \t drawImage.frame = self.view.frame; \t [self.view addSubview:drawImage]; [drawImage.image drawInRect:CGRectMake(0,0,drawImage.frame.size.width,drawImage.frame.size.height)]; –