@@ -125,6 +125,8 @@ open class BarcodeScannerController: UIViewController {
125125 } )
126126 }
127127 }
128+
129+ public var barCodeFocusViewType : FocusViewType = . animated
128130
129131 /// The current torch mode on the capture device.
130132 var torchMode : TorchMode = . off {
@@ -202,7 +204,14 @@ open class BarcodeScannerController: UIViewController {
202204 name: NSNotification . Name. UIApplicationWillEnterForeground,
203205 object: nil )
204206 }
205-
207+
208+ open override func viewWillAppear( _ animated: Bool ) {
209+ super. viewWillAppear ( animated)
210+ setupFrame ( )
211+
212+ headerView. isHidden = !isBeingPresented
213+ }
214+
206215 open override func viewDidAppear( _ animated: Bool ) {
207216 super. viewDidAppear ( animated)
208217 animateFocusView ( )
@@ -300,15 +309,14 @@ open class BarcodeScannerController: UIViewController {
300309 flashButton. alpha = alpha
301310 settingsButton. isHidden = status. state != . unauthorized
302311 }
303-
312+
304313 // MARK: - Layout
305- open override func viewWillLayoutSubviews( ) {
306- super. viewWillLayoutSubviews ( )
307-
314+
315+ func setupFrame( ) {
308316 headerView. frame = CGRect ( x: 0 , y: 0 , width: view. frame. width, height: 64 )
309317 flashButton. frame = CGRect ( x: view. frame. width - 50 , y: 73 , width: 37 , height: 37 )
310318 infoView. frame = infoFrame
311-
319+
312320 if let videoPreviewLayer = videoPreviewLayer {
313321 videoPreviewLayer. frame = view. layer. bounds
314322 if let connection = videoPreviewLayer. connection, connection. isVideoOrientationSupported {
@@ -322,7 +330,11 @@ open class BarcodeScannerController: UIViewController {
322330 }
323331 }
324332
325- center ( subview: focusView, inSize: CGSize ( width: 218 , height: 150 ) )
333+ if barCodeFocusViewType == . oneDimension {
334+ center ( subview: focusView, inSize: CGSize ( width: 280 , height: 80 ) )
335+ } else {
336+ center ( subview: focusView, inSize: CGSize ( width: 218 , height: 150 ) )
337+ }
326338 center ( subview: settingsButton, inSize: CGSize ( width: 150 , height: 50 ) )
327339
328340 headerView. isHidden = !isBeingPresented
@@ -376,14 +388,17 @@ open class BarcodeScannerController: UIViewController {
376388 func animateFocusView( ) {
377389 focusView. layer. removeAllAnimations ( )
378390 focusView. isHidden = false
379-
380- UIView . animate ( withDuration: 1.0 , delay: 0 ,
381- options: [ . repeat , . autoreverse, . beginFromCurrentState] ,
382- animations: {
383- self . center ( subview: self . focusView, inSize: CGSize ( width: 280 , height: 80 ) )
384- } , completion: nil )
385-
386- view. setNeedsLayout ( )
391+
392+ setupFrame ( )
393+
394+ if barCodeFocusViewType == . animated {
395+ UIView . animate ( withDuration: 1.0 , delay: 0 ,
396+ options: [ . repeat , . autoreverse, . beginFromCurrentState] ,
397+ animations: {
398+ self . center ( subview: self . focusView, inSize: CGSize ( width: 280 , height: 80 ) )
399+ } , completion: nil )
400+ }
401+ view. setNeedsLayout ( )
387402 }
388403
389404 // MARK: - Actions
0 commit comments