テーマを追加することで、Digits の見栄えをあなたのアプリのようにすることができます。 Digits では DGTAppearance インスタンスを使ってDigits UIエレメントのスタイルを指定します。
DGTAppearance は backgroundColor プロパティとaccentColorプロパティを保持しています。残りの色はこれら二つの色を基にして算出されます。
Theming DigitsYou can make Digits look and feel like your app by adding a theme. Digits uses
|
例えば、タップハンドラdidTapButtonを使ってカスタムボタンを設定する場合 :
// Objective-C
- (void)didTapButton {
// 既に標準カラーで初期化されているDGTAppearance オブジェクトを作成:
DGTAppearance *digitsAppearance =
[[DGTAppearance alloc] init];
// color プロパティを変更して見栄えをカスタマイズ:
digitsAppearance.backgroundColor = [UIColor
colorWithRed:81/255.
green:208/255.
blue:90/255.
alpha:1];
digitsAppearance.accentColor =
[UIColor redColor];
// カスタムappearanceで認証フローを開始。 Nil パラメータを設定すると既定値が使われる。
Digits *digits = [Digits sharedInstance];
[digits authenticateWithDigitsAppearance:digitsAppearance
viewController:nil
title:nil
completion:^(DGTSession *session,
NSError *error) {
// sessionオブジェクトとerrorオブジェクトを調べる
}];
}
// Swift
func didTapButton(sender: AnyObject) {
// 既に標準カラーで初期化されているDGTAppearance オブジェクトを作成:
let digitsAppearance = DGTAppearance()
// color プロパティを変更して見栄えをカスタマイズ:
digitsAppearance.backgroundColor = UIColor.blackColor()
digitsAppearance.accentColor = UIColor.greenColor()
// カスタムappearanceで認証フローを開始。 Nil パラメータを設定すると既定値が使われる。
let digits = Digits.sharedInstance()
digits.authenticateWithDigitsAppearance(digitsAppearance, viewController: nil, title: nil) { (session, error) in
// sessionオブジェクトとerrorオブジェクトを調べる
}
}
|
For example, if you have set up a custom button with the tap handler
// Objective-C
- (void)didTapButton {
// Create an already initialized DGTAppearance object with standard colors:
DGTAppearance *digitsAppearance =
[[DGTAppearance alloc] init];
// Change color properties to customize the look:
digitsAppearance.backgroundColor = [UIColor
colorWithRed:81/255.
green:208/255.
blue:90/255.
alpha:1];
digitsAppearance.accentColor =
[UIColor redColor];
// Start the authentication flow with the custom appearance. Nil parameters for default values.
Digits *digits = [Digits sharedInstance];
[digits authenticateWithDigitsAppearance:digitsAppearance
viewController:nil
title:nil
completion:^(DGTSession *session,
NSError *error) {
// Inspect session/error objects
}];
}
// Swift
func didTapButton(sender: AnyObject) {
// Create and initialize a DGTAppearance object with standard colors:
let digitsAppearance = DGTAppearance()
// Change color properties to customize the look:
digitsAppearance.backgroundColor = UIColor.blackColor()
digitsAppearance.accentColor = UIColor.greenColor()
// Start the authentication flow with the custom appearance. Nil parameters for default values.
let digits = Digits.sharedInstance()
digits.authenticateWithDigitsAppearance(digitsAppearance, viewController: nil, title: nil) { (session, error) in
// Inspect session/error objects
}
}
|