mirror of
https://github.com/simplezhli/flutter_barcode_reader.git
synced 2024-11-01 07:39:22 +08:00
Fixed the position of the scan line
This commit is contained in:
parent
e0cc5c3bc2
commit
770bb47d6c
@ -89,10 +89,10 @@
|
|||||||
CGFloat frameHeight = rect.size.height;
|
CGFloat frameHeight = rect.size.height;
|
||||||
|
|
||||||
BOOL isLandscape = frameWidth > frameHeight;
|
BOOL isLandscape = frameWidth > frameHeight;
|
||||||
CGFloat widthOnPotrait = isLandscape ? frameHeight : frameWidth;
|
CGFloat widthOnPortrait = isLandscape ? frameHeight : frameWidth;
|
||||||
CGFloat heightMultiplier = 3.0/4.0; // 4:3 aspect ratio
|
CGFloat scanRectWidth = widthOnPortrait * 0.8f;
|
||||||
CGFloat scanRectWidth = widthOnPotrait * 0.8f;
|
CGFloat aspectRatio = 3.0/4.0;
|
||||||
CGFloat scanRectHeight = scanRectWidth * heightMultiplier;
|
CGFloat scanRectHeight = scanRectWidth * aspectRatio;
|
||||||
|
|
||||||
if(isLandscape) {
|
if(isLandscape) {
|
||||||
CGFloat navbarHeight = 32;
|
CGFloat navbarHeight = 32;
|
||||||
@ -106,8 +106,8 @@
|
|||||||
|
|
||||||
- (CGRect)scanLineRect {
|
- (CGRect)scanLineRect {
|
||||||
CGRect scanRect = [self scanRect];
|
CGRect scanRect = [self scanRect];
|
||||||
CGRect rect = self.frame;
|
CGFloat positionY = scanRect.origin.y + (scanRect.size.height / 2);
|
||||||
return CGRectMake(scanRect.origin.x, rect.size.height / 2, scanRect.size.width, 1);
|
return CGRectMake(scanRect.origin.x, positionY, scanRect.size.width, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
Loading…
Reference in New Issue
Block a user