Skip to content

UIAppearance

The Face SDK exposes to the public API several UIViews that are used internally. The easiest way to customize them is to use the built-in UIAppearance proxy.

Info

For more information on UIAppearance, see the official Apple Documentation.

Properties that are supposed to be modified via UIAppearance are marked with a standard UI_APPEARANCE_SELECTOR qualifier. Please see the SDK Reference guide to find out the complete list of supported customizations.

Warning

Please note that it is important to apply the UIAppearance configuration as early as possible in your application lifecycle. In the provided example, the configuration is applied right in the AppDelegate application(_: UIApplication, didFinishLaunchingWithOptions:....

Liveness Appearance Customization Example

import UIKit
import FaceSDK

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // HintView Styling
        let hintViewAppearance = HintView.appearance(whenContainedInInstancesOf: [LivenessContentView.self])
        hintViewAppearance.cornerRadius = 0
        hintViewAppearance.setBackgroundColor(.yellow, for: .front)
        hintViewAppearance.setTextColor(.black, for: .front)

        let hintLabelAppearance = UILabel.appearance(whenContainedInInstancesOf: [HintView.self, LivenessContentView.self])
        hintLabelAppearance.font = UIFont(name: "AmericanTypewriter", size: 17)

        // Toolbar Styling
        let toolbarAppearance = CameraToolbarView.appearance(whenContainedInInstancesOf: [LivenessContentView.self])
        toolbarAppearance.backgroundColor = .yellow
        toolbarAppearance.setTintColor(.black, for: .rear)
        toolbarAppearance.setTintColor(.black, for: .front)

        return true
    }
}
#import "AppDelegate.h"
#import <FaceSDK/FaceSDK.h>

@interface AppDelegate ()
@end

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // HintView Styling
    RFSHintView *hintViewAppearance = [RFSHintView appearanceWhenContainedInInstancesOfClasses:@[RFSLivenessContentView.class]];
    hintViewAppearance.cornerRadius = 0;
    [hintViewAppearance setBackgroundColor:UIColor.yellowColor forState:RFSHintViewStateFront];
    [hintViewAppearance setBackgroundColor:UIColor.blackColor forState:RFSHintViewStateFront];

    UILabel *hintLabelAppearance = [UILabel appearanceWhenContainedInInstancesOfClasses:@[RFSHintView.class, RFSLivenessContentView.class]];
    hintLabelAppearance.font = [UIFont systemFontOfSize:15 weight:UIFontWeightBold];

    // Toolbar Styling
    RFSCameraToolbarView *toolbarAppearance = [RFSCameraToolbarView appearanceWhenContainedInInstancesOfClasses:@[RFSLivenessContentView.class]];
    toolbarAppearance.backgroundColor = UIColor.yellowColor;
    [toolbarAppearance setTintColor:UIColor.blackColor forState:RFSCameraToolbarViewStateFront];
    [toolbarAppearance setTintColor:UIColor.blackColor forState:RFSCameraToolbarViewStateRear];

    return YES;
}

@end

See more customization examples in our open-source Catalog App.

Info

Sometimes, UIAppearance is just not enough to get the UI adjustments you want. Please see Class Overriding for layout changes and even more fine-grained customizations.

Back to top