Skip to main content

Advanced Configurations

Customize the Overlay Appearance

To customize the appearance of the overlay, you can implement a LabelCaptureBasicOverlayDelegate.

The method brushForLabel is called every time a label is captured, and brushForField is called for each of its fields to determine the brush for the label or field.

import ScanditLabelCapture

extension YourScanViewController: LabelCaptureBasicOverlayDelegate {
func labelCaptureBasicOverlay(_ overlay: LabelCaptureBasicOverlay,
brushFor field: LabelField,
of label: CapturedLabel) -> Brush? {
return brush(for: field)
}

func labelCaptureBasicOverlay(_ overlay: LabelCaptureBasicOverlay,
brushFor label: CapturedLabel) -> Brush? {
/*
* Customize the appearance of the overlay for the full label.
* In this example, we always disable label overlays by returning nil.
*/
return nil
}

func labelCaptureBasicOverlay(_ overlay: LabelCaptureBasicOverlay,
didTap label: CapturedLabel) {
/*
* Handle user tap gestures on the label.
*/
}

private func brush(for field: LabelField) -> Brush {
let fillColor: UIColor
let strokeColor: UIColor
switch Field(rawValue: field.name) {
case "<your-barcode-field-name>":
fillColor = .systemCyan.withAlphaComponent(0.5)
strokeColor = .systemCyan
case "<your-expiry-date-field-name>":
fillColor = .systemOrange.withAlphaComponent(0.5)
strokeColor = .systemOrange
case .none:
fillColor = .clear
strokeColor = .clear
}
return Brush(fill: fillColor, stroke: strokeColor, strokeWidth: 1)
}
}

Validation Flow

Validation Flow is a workflow available in Smart Label Capture to improve the accuracy and completeness of scanned label data in real-world environments. The following settings and configurations are available to customize the validation flow:

UI Elements

ConstantDefault ValueDescription
missingFieldErrorTextThis field is required.Shown under the field when it's left empty.
missingFieldHintTextPlease fill in missing fields.Displayed when required fields are missing.
standbyHintTextScanning paused to conserve battery.Used in Standby State.
validationHintTextlabel fields captured.Displays scan status before this message.
validationErrorTextInvalid input.Appears on incorrect manual input.
manualInputButtonTextInput manuallyLabel for the manual input button.

See the LabelCaptureValidationFlowSettings API reference for more details.

Viewfinder and Layout

ElementDefault ValueDescription
timeout10sMax scan duration before transitioning.
dimming_layerrgba(0, 0, 0, 0.5)Dim background during frozen states.
label_viewfinderRectangularViewfinderStyleLightUsed in Initial and Validation States.
label_margins90% width, 40% heightInitial/Validation scan frame.
target_viewfinderRectangularViewfinderStyleLightUsed in Target Scanning State.
target_margins90% width, 15% heightFocused scan margins for individual fields.

See the LabelCaptureValidationFlowOverlay API reference for more details.