Skip to content

Commit a1a3a3a

Browse files
committed
for some reason setupFrames is not working properly when it was being called generating wrong size focus views. this fixes it.
1 parent 1bbd169 commit a1a3a3a

1 file changed

Lines changed: 14 additions & 6 deletions

File tree

Sources/BarcodeScannerController.swift

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,14 @@ open class BarcodeScannerController: UIViewController {
204204
name: NSNotification.Name.UIApplicationWillEnterForeground,
205205
object: nil)
206206
}
207-
207+
208+
open override func viewWillAppear(_ animated: Bool) {
209+
super.viewWillAppear(animated)
210+
setupFrame()
211+
212+
headerView.isHidden = !isBeingPresented
213+
}
214+
208215
open override func viewDidAppear(_ animated: Bool) {
209216
super.viewDidAppear(animated)
210217
animateFocusView()
@@ -302,15 +309,14 @@ open class BarcodeScannerController: UIViewController {
302309
flashButton.alpha = alpha
303310
settingsButton.isHidden = status.state != .unauthorized
304311
}
305-
312+
306313
// MARK: - Layout
307-
open override func viewWillLayoutSubviews() {
308-
super.viewWillLayoutSubviews()
309-
314+
315+
func setupFrame() {
310316
headerView.frame = CGRect(x: 0, y: 0, width: view.frame.width, height: 64)
311317
flashButton.frame = CGRect(x: view.frame.width - 50, y: 73, width: 37, height: 37)
312318
infoView.frame = infoFrame
313-
319+
314320
if let videoPreviewLayer = videoPreviewLayer {
315321
videoPreviewLayer.frame = view.layer.bounds
316322
if let connection = videoPreviewLayer.connection, connection.isVideoOrientationSupported {
@@ -383,6 +389,8 @@ open class BarcodeScannerController: UIViewController {
383389
focusView.layer.removeAllAnimations()
384390
focusView.isHidden = false
385391

392+
setupFrame()
393+
386394
if barCodeFocusViewType == .animated {
387395
UIView.animate(withDuration: 1.0, delay:0,
388396
options: [.repeat, .autoreverse, .beginFromCurrentState],

0 commit comments

Comments
 (0)