mirror of
https://github.com/simplezhli/flutter_barcode_reader.git
synced 2024-12-23 20:49:23 +08:00
Fixed the size of the preview overlay
This commit is contained in:
parent
06f38e0b53
commit
e0cc5c3bc2
@ -16,6 +16,7 @@
|
|||||||
CGRect reversedBounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width);
|
CGRect reversedBounds = CGRectMake(bounds.origin.x, bounds.origin.y, bounds.size.height, bounds.size.width);
|
||||||
self.previewView.bounds = reversedBounds;
|
self.previewView.bounds = reversedBounds;
|
||||||
self.previewView.frame = reversedBounds;
|
self.previewView.frame = reversedBounds;
|
||||||
|
[self.scanRect stopAnimating];
|
||||||
[self.scanRect removeFromSuperview];
|
[self.scanRect removeFromSuperview];
|
||||||
[self setupScanRect:reversedBounds];
|
[self setupScanRect:reversedBounds];
|
||||||
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
|
||||||
|
@ -83,13 +83,25 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)scanRect {
|
- (CGRect)scanRect {
|
||||||
CGRect rect = self.frame;
|
CGRect rect = self.frame;
|
||||||
CGFloat heightMultiplier = 3.0/4.0; // 4:3 aspect ratio
|
|
||||||
CGFloat scanRectWidth = rect.size.width * 0.8f;
|
CGFloat frameWidth = rect.size.width;
|
||||||
CGFloat scanRectHeight = scanRectWidth * heightMultiplier;
|
CGFloat frameHeight = rect.size.height;
|
||||||
CGFloat scanRectOriginX = (rect.size.width / 2) - (scanRectWidth / 2);
|
|
||||||
CGFloat scanRectOriginY = (rect.size.height / 2) - (scanRectHeight / 2);
|
BOOL isLandscape = frameWidth > frameHeight;
|
||||||
return CGRectMake(scanRectOriginX, scanRectOriginY, scanRectWidth, scanRectHeight);
|
CGFloat widthOnPotrait = isLandscape ? frameHeight : frameWidth;
|
||||||
|
CGFloat heightMultiplier = 3.0/4.0; // 4:3 aspect ratio
|
||||||
|
CGFloat scanRectWidth = widthOnPotrait * 0.8f;
|
||||||
|
CGFloat scanRectHeight = scanRectWidth * heightMultiplier;
|
||||||
|
|
||||||
|
if(isLandscape) {
|
||||||
|
CGFloat navbarHeight = 32;
|
||||||
|
frameHeight += navbarHeight;
|
||||||
|
}
|
||||||
|
|
||||||
|
CGFloat scanRectOriginX = (frameWidth - scanRectWidth) / 2;
|
||||||
|
CGFloat scanRectOriginY = (frameHeight - scanRectHeight) / 2;
|
||||||
|
return CGRectMake(scanRectOriginX, scanRectOriginY, scanRectWidth, scanRectHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGRect)scanLineRect {
|
- (CGRect)scanLineRect {
|
||||||
|
Loading…
Reference in New Issue
Block a user