mirror of
https://github.com/zxing/zxing.git
synced 2025-03-05 20:48:51 -08:00
[ios] add cancel button title customization possibility on OverlayView
git-svn-id: https://zxing.googlecode.com/svn/trunk@2409 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
7011f4fcfc
commit
c4b3675180
|
@ -25,8 +25,10 @@
|
||||||
UILabel *instructionsLabel;
|
UILabel *instructionsLabel;
|
||||||
id<CancelDelegate> delegate;
|
id<CancelDelegate> delegate;
|
||||||
BOOL oneDMode;
|
BOOL oneDMode;
|
||||||
|
BOOL cancelEnabled;
|
||||||
CGRect cropRect;
|
CGRect cropRect;
|
||||||
NSString *displayedMessage;
|
NSString *displayedMessage;
|
||||||
|
NSString *cancelButtonTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property (nonatomic, retain) NSMutableArray* points;
|
@property (nonatomic, retain) NSMutableArray* points;
|
||||||
|
@ -34,6 +36,8 @@
|
||||||
@property (nonatomic, assign) BOOL oneDMode;
|
@property (nonatomic, assign) BOOL oneDMode;
|
||||||
@property (nonatomic, assign) CGRect cropRect;
|
@property (nonatomic, assign) CGRect cropRect;
|
||||||
@property (nonatomic, copy) NSString *displayedMessage;
|
@property (nonatomic, copy) NSString *displayedMessage;
|
||||||
|
@property (nonatomic, retain) NSString *cancelButtonTitle;
|
||||||
|
@property (nonatomic, assign) BOOL cancelEnabled;
|
||||||
|
|
||||||
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled showLicense:(BOOL)shouldShowLicense;
|
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled showLicense:(BOOL)shouldShowLicense;
|
||||||
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled;
|
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled;
|
||||||
|
|
|
@ -37,6 +37,8 @@ static const CGFloat kLicenseButtonPadding = 10;
|
||||||
@synthesize cropRect;
|
@synthesize cropRect;
|
||||||
@synthesize instructionsLabel;
|
@synthesize instructionsLabel;
|
||||||
@synthesize displayedMessage;
|
@synthesize displayedMessage;
|
||||||
|
@synthesize cancelButtonTitle;
|
||||||
|
@synthesize cancelEnabled;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled {
|
- (id)initWithFrame:(CGRect)theFrame cancelEnabled:(BOOL)isCancelEnabled oneDMode:(BOOL)isOneDModeEnabled {
|
||||||
|
@ -57,26 +59,6 @@ static const CGFloat kLicenseButtonPadding = 10;
|
||||||
|
|
||||||
self.backgroundColor = [UIColor clearColor];
|
self.backgroundColor = [UIColor clearColor];
|
||||||
self.oneDMode = isOneDModeEnabled;
|
self.oneDMode = isOneDModeEnabled;
|
||||||
if (isCancelEnabled) {
|
|
||||||
UIButton *butt = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
|
||||||
self.cancelButton = butt;
|
|
||||||
[cancelButton setTitle:NSLocalizedStringWithDefaultValue(@"OverlayView cancel button title", nil, [NSBundle mainBundle], @"Cancel", @"Cancel") forState:UIControlStateNormal];
|
|
||||||
if (oneDMode) {
|
|
||||||
[cancelButton setTransform:CGAffineTransformMakeRotation(M_PI/2)];
|
|
||||||
|
|
||||||
[cancelButton setFrame:CGRectMake(20, 175, 45, 130)];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
CGSize theSize = CGSizeMake(100, 50);
|
|
||||||
CGRect theRect = CGRectMake((theFrame.size.width - theSize.width) / 2, cropRect.origin.y + cropRect.size.height + 20, theSize.width, theSize.height);
|
|
||||||
[cancelButton setFrame:theRect];
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[cancelButton addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchUpInside];
|
|
||||||
[self addSubview:cancelButton];
|
|
||||||
[self addSubview:imageView];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (showLicenseButton) {
|
if (showLicenseButton) {
|
||||||
self.licenseButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
|
self.licenseButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
|
||||||
|
@ -89,6 +71,7 @@ static const CGFloat kLicenseButtonPadding = 10;
|
||||||
|
|
||||||
[self addSubview:licenseButton];
|
[self addSubview:licenseButton];
|
||||||
}
|
}
|
||||||
|
self.cancelEnabled = isCancelEnabled;
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -123,6 +106,7 @@ static const CGFloat kLicenseButtonPadding = 10;
|
||||||
[_points release];
|
[_points release];
|
||||||
[instructionsLabel release];
|
[instructionsLabel release];
|
||||||
[displayedMessage release];
|
[displayedMessage release];
|
||||||
|
[cancelButtonTitle release],
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -241,6 +225,31 @@ static const CGFloat kLicenseButtonPadding = 10;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (self.cancelEnabled) {
|
||||||
|
UIButton *butt = [UIButton buttonWithType:UIButtonTypeRoundedRect];
|
||||||
|
self.cancelButton = butt;
|
||||||
|
if ([self.cancelButtonTitle length] > 0 ) {
|
||||||
|
[cancelButton setTitle:self.cancelButtonTitle forState:UIControlStateNormal];
|
||||||
|
} else {
|
||||||
|
[cancelButton setTitle:NSLocalizedStringWithDefaultValue(@"OverlayView cancel button title", nil, [NSBundle mainBundle], @"Cancel", @"Cancel") forState:UIControlStateNormal];
|
||||||
|
}
|
||||||
|
if (oneDMode) {
|
||||||
|
[cancelButton setTransform:CGAffineTransformMakeRotation(M_PI/2)];
|
||||||
|
|
||||||
|
[cancelButton setFrame:CGRectMake(20, 175, 45, 130)];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
CGSize theSize = CGSizeMake(100, 50);
|
||||||
|
CGRect theRect = CGRectMake((rect.size.width - theSize.width) / 2, cropRect.origin.y + cropRect.size.height + 20, theSize.width, theSize.height);
|
||||||
|
[cancelButton setFrame:theRect];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[cancelButton addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchUpInside];
|
||||||
|
[self addSubview:cancelButton];
|
||||||
|
[self addSubview:imageView];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue