@@ -203,14 +203,6 @@ open class BarcodeScannerController: UIViewController {
203203 object: nil )
204204 }
205205
206- open override func viewWillAppear( _ animated: Bool ) {
207- super. viewWillAppear ( animated)
208-
209- setupFrames ( )
210- infoView. setupFrames ( )
211- headerView. isHidden = !isBeingPresented
212- }
213-
214206 open override func viewDidAppear( _ animated: Bool ) {
215207 super. viewDidAppear ( animated)
216208 animateFocusView ( )
@@ -268,7 +260,7 @@ open class BarcodeScannerController: UIViewController {
268260 output. metadataObjectTypes = metadata
269261 videoPreviewLayer? . session = captureSession
270262
271- setupFrames ( )
263+ view . setNeedsLayout ( )
272264 }
273265
274266 // MARK: - Reset
@@ -310,11 +302,9 @@ open class BarcodeScannerController: UIViewController {
310302 }
311303
312304 // MARK: - Layout
305+ open override func viewWillLayoutSubviews( ) {
306+ super. viewWillLayoutSubviews ( )
313307
314- /**
315- Sets frames of the subviews.
316- */
317- func setupFrames( ) {
318308 headerView. frame = CGRect ( x: 0 , y: 0 , width: view. frame. width, height: 64 )
319309 flashButton. frame = CGRect ( x: view. frame. width - 50 , y: 73 , width: 37 , height: 37 )
320310 infoView. frame = infoFrame
@@ -329,6 +319,8 @@ open class BarcodeScannerController: UIViewController {
329319
330320 center ( subview: focusView, inSize: CGSize ( width: 218 , height: 150 ) )
331321 center ( subview: settingsButton, inSize: CGSize ( width: 150 , height: 50 ) )
322+
323+ headerView. isHidden = !isBeingPresented
332324 }
333325
334326 /**
@@ -386,13 +378,13 @@ open class BarcodeScannerController: UIViewController {
386378 focusView. layer. removeAllAnimations ( )
387379 focusView. isHidden = false
388380
389- setupFrames ( )
390-
391381 UIView . animate ( withDuration: 1.0 , delay: 0 ,
392382 options: [ . repeat , . autoreverse, . beginFromCurrentState] ,
393383 animations: {
394384 self . center ( subview: self . focusView, inSize: CGSize ( width: 280 , height: 80 ) )
395385 } , completion: nil )
386+
387+ view. setNeedsLayout ( )
396388 }
397389
398390 // MARK: - Actions
0 commit comments