mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-02-22 04:52:51 +08:00
iOS overlay view supporting to show the indicated image titled "overlayImage.png"
This commit is contained in:
parent
f704689200
commit
9183df4f92
@ -89,6 +89,8 @@ typedef NSUInteger CDVMediaType;
|
||||
@property (strong) NSMutableDictionary *metadata;
|
||||
@property (strong, nonatomic) CLLocationManager *locationManager;
|
||||
@property (strong) NSData* data;
|
||||
@property (assign) BOOL isOverlayView;
|
||||
@property (strong) UIView* overlayView;
|
||||
|
||||
/*
|
||||
* getPicture
|
||||
@ -101,6 +103,8 @@ typedef NSUInteger CDVMediaType;
|
||||
* quality: integer between 1 and 100
|
||||
*/
|
||||
- (void)takePicture:(CDVInvokedUrlCommand*)command;
|
||||
- (void)takePictureOverlayView:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
- (void)cleanup:(CDVInvokedUrlCommand*)command;
|
||||
- (void)repositionPopover:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
|
@ -104,7 +104,7 @@ static NSString* toBase64(NSData* data) {
|
||||
org_apache_cordova_validArrowDirections = [[NSSet alloc] initWithObjects:[NSNumber numberWithInt:UIPopoverArrowDirectionUp], [NSNumber numberWithInt:UIPopoverArrowDirectionDown], [NSNumber numberWithInt:UIPopoverArrowDirectionLeft], [NSNumber numberWithInt:UIPopoverArrowDirectionRight], [NSNumber numberWithInt:UIPopoverArrowDirectionAny], nil];
|
||||
}
|
||||
|
||||
@synthesize hasPendingOperation, pickerController, locationManager;
|
||||
@synthesize hasPendingOperation, pickerController, locationManager, isOverlayView;
|
||||
|
||||
- (NSURL*) urlTransformer:(NSURL*)url
|
||||
{
|
||||
@ -138,6 +138,7 @@ static NSString* toBase64(NSData* data) {
|
||||
|
||||
- (void)takePicture:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
isOverlayView = NO;
|
||||
self.hasPendingOperation = YES;
|
||||
__weak CDVCamera* weakSelf = self;
|
||||
|
||||
@ -183,6 +184,12 @@ static NSString* toBase64(NSData* data) {
|
||||
}];
|
||||
}
|
||||
|
||||
- (void)takePictureOverlayView:(CDVInvokedUrlCommand*)command
|
||||
{
|
||||
isOverlayView = YES;
|
||||
[self takePicture:command];
|
||||
|
||||
}
|
||||
- (void)showCameraPicker:(NSString*)callbackId withOptions:(CDVPictureOptions *) pictureOptions
|
||||
{
|
||||
// Perform UI operations on the main thread
|
||||
@ -195,6 +202,26 @@ static NSString* toBase64(NSData* data) {
|
||||
// we need to capture this state for memory warnings that dealloc this object
|
||||
cameraPicker.webView = self.webView;
|
||||
|
||||
//It's a overlay view block to show the indicated image titled "overlayImage.png"
|
||||
if(isOverlayView) {
|
||||
NSURL *bundleURL = [[NSBundle mainBundle] URLForResource:@"CDVCamera" withExtension:@"bundle"];
|
||||
NSBundle *bundle = [NSBundle bundleWithURL:bundleURL];
|
||||
NSString *imagePath = [bundle pathForResource:@"overlayImage" ofType:@"png"];
|
||||
UIImage *imgSrc = [UIImage imageWithContentsOfFile:imagePath];
|
||||
UIButton *btnOverlay = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.pickerController.view.bounds.size.width, self.pickerController.view.bounds.size.height)];
|
||||
[btnOverlay setImage:imgSrc forState:UIControlStateNormal];
|
||||
[btnOverlay setImage:imgSrc forState:UIControlStateSelected];
|
||||
[btnOverlay setContentMode:UIViewContentModeCenter];
|
||||
[self.overlayView addSubview:btnOverlay];
|
||||
[self.overlayView.layer setOpaque:YES];
|
||||
self.overlayView.opaque = NO;
|
||||
[self.overlayView setBackgroundColor:UIColor.clearColor];
|
||||
[self.overlayView setTintColor:UIColor.clearColor];
|
||||
[self.overlayView setAlpha:1.0];
|
||||
[self.overlayView setBackgroundColor:UIColor.whiteColor];
|
||||
pickerController.cameraOverlayView = self.overlayView;
|
||||
}
|
||||
|
||||
// If a popover is already open, close it; we only want one at a time.
|
||||
if (([[self pickerController] pickerPopoverController] != nil) && [[[self pickerController] pickerPopoverController] isPopoverVisible]) {
|
||||
[[[self pickerController] pickerPopoverController] dismissPopoverAnimated:YES];
|
||||
|
Loading…
Reference in New Issue
Block a user