mirror of
https://github.com/zxing/zxing.git
synced 2024-11-10 04:54:04 -08:00
Move widget cancel button subview from drawRect to init. Remove image stuff that's not being used.
git-svn-id: https://zxing.googlecode.com/svn/trunk@2456 59b500cc-1b3d-0410-9834-0bbf25fbcc57
This commit is contained in:
parent
1f0ac619b0
commit
5c0aef5357
|
@ -19,7 +19,6 @@
|
|||
@protocol CancelDelegate;
|
||||
|
||||
@interface OverlayView : UIView {
|
||||
UIImageView *imageView;
|
||||
NSMutableArray *_points;
|
||||
UIButton *cancelButton;
|
||||
UILabel *instructionsLabel;
|
||||
|
|
|
@ -72,6 +72,18 @@ static const CGFloat kLicenseButtonPadding = 10;
|
|||
[self addSubview:licenseButton];
|
||||
}
|
||||
self.cancelEnabled = isCancelEnabled;
|
||||
|
||||
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];
|
||||
}
|
||||
[cancelButton addTarget:self action:@selector(cancel:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[self addSubview:cancelButton];
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -102,7 +114,6 @@ static const CGFloat kLicenseButtonPadding = 10;
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (void) dealloc {
|
||||
[imageView release];
|
||||
[_points release];
|
||||
[instructionsLabel release];
|
||||
[displayedMessage release];
|
||||
|
@ -161,10 +172,6 @@ static const CGFloat kLicenseButtonPadding = 10;
|
|||
}
|
||||
CGContextRef c = UIGraphicsGetCurrentContext();
|
||||
|
||||
if (nil != _points) {
|
||||
// [imageView.image drawAtPoint:cropRect.origin];
|
||||
}
|
||||
|
||||
CGFloat white[4] = {1.0f, 1.0f, 1.0f, 1.0f};
|
||||
CGContextSetStrokeColor(c, white);
|
||||
CGContextSetFillColor(c, white);
|
||||
|
@ -225,60 +232,6 @@ 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];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
- (void) setImage:(UIImage*)image {
|
||||
//if( nil == imageView ) {
|
||||
// imageView = [[UIImageView alloc] initWithImage:image];
|
||||
// imageView.alpha = 0.5;
|
||||
// } else {
|
||||
imageView.image = image;
|
||||
//}
|
||||
|
||||
//CGRect frame = imageView.frame;
|
||||
//frame.origin.x = self.cropRect.origin.x;
|
||||
//frame.origin.y = self.cropRect.origin.y;
|
||||
//imageView.frame = CGRectMake(0,0, 30, 50);
|
||||
|
||||
//[_points release];
|
||||
//_points = nil;
|
||||
//self.backgroundColor = [UIColor clearColor];
|
||||
|
||||
//[self setNeedsDisplay];
|
||||
}
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
- (UIImage*) image {
|
||||
return imageView.image;
|
||||
}
|
||||
|
||||
|
||||
|
@ -306,4 +259,19 @@ static const CGFloat kLicenseButtonPadding = 10;
|
|||
}
|
||||
|
||||
|
||||
- (void)layoutSubviews {
|
||||
[super layoutSubviews];
|
||||
if (cancelButton) {
|
||||
if (oneDMode) {
|
||||
[cancelButton setTransform:CGAffineTransformMakeRotation(M_PI/2)];
|
||||
[cancelButton setFrame:CGRectMake(20, 175, 45, 130)];
|
||||
} else {
|
||||
CGSize theSize = CGSizeMake(100, 50);
|
||||
CGRect rect = self.frame;
|
||||
CGRect theRect = CGRectMake((rect.size.width - theSize.width) / 2, cropRect.origin.y + cropRect.size.height + 20, theSize.width, theSize.height);
|
||||
[cancelButton setFrame:theRect];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue