BRAppearanceTheme
Objective-C
@interface BRAppearanceTheme : NSObject
Swift
class BRAppearanceTheme : NSObject
Customizes colors and icons in the SDK’s stock scan UI (help sheet, onboarding, camera toolbar, and related surfaces).
Subclass BRAppearanceTheme and override colorForKey: and / or
imageForKey: to supply your own values, then assign an instance to
BRScanOptions.appearance before you start a scan. Both methods use an
opt-in model: return nil for any key you don’t want to customize and
the SDK keeps its built-in value. The base implementation returns nil
for every key, so an unmodified BRAppearanceTheme is equivalent to
leaving BRScanOptions.appearance set to nil.
The SDK queries the theme each time the relevant control is configured, so values may be read more than once per scan session and should be cheap to produce. You can swap themes between scans (for example, to react to light / dark mode) by assigning a new instance.
Example (Objective-C):
@interface MyAppearanceTheme : BRAppearanceTheme
@end
@implementation MyAppearanceTheme
- (UIColor *)colorForKey:(BRAppearanceColorKey)key {
if (key == BRAppearanceColorKeyHelpModalCloseButtonBackground) {
return UIColor.systemBlueColor;
}
return nil;
}
@end
BRScanOptions *options = [BRScanOptions new];
options.appearance = [MyAppearanceTheme new];
Example (Swift):
final class MyAppearanceTheme: BRAppearanceTheme {
override func color(for key: BRAppearanceColorKey) -> UIColor? {
key == .helpModalCloseButtonBackground ? .systemBlue : nil
}
}
let options = BRScanOptions()
options.appearance = MyAppearanceTheme()
-
Returns a color for the given key, or
nilto keep the SDK default for that element.Override in a subclass to supply custom colors. The base implementation always returns
nil.Declaration
Objective-C
- (nullable UIColor *)colorForKey:(BRAppearanceColorKey)key;Swift
func color(for key: BRAppearanceColorKey) -> UIColor? -
Returns an image for the given key, or
nilto keep the SDK default asset.Override in a subclass to supply custom icons. The base implementation always returns
nil.Declaration
Objective-C
- (nullable UIImage *)imageForKey:(BRAppearanceIconKey)key;Swift
func image(for key: BRAppearanceIconKey) -> UIImage?
View on GitHub