LAContext 更改 UIAlertController 按钮标题
LAContext change UIAlertController button title
我已经使用 LAContext
将 TouchID 整合到我的应用程序中,如下所示:
但是,我想将按钮标题的名称从 "Enter Password" 更改为输入 "Enter Security Code"(或类似名称),如下所示:
我该如何更改按钮标题?
这是 LAContext
documentation,这是我的代码:
var touchIDContext = LAContext()
if touchIDContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &msgError) {
touchIDContext.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: touchIDMessage) {
(success: Bool, error: NSError!) -> Void in
if success {
println("Success")
} else {
println("Error: \(error)")
}
}
}
设置 localizedFallbackTitle 属性:
Objective-C:
LAContext *context = [[LAContext alloc] init];
context.localizedFallbackTitle = @"YOUR TEXT HERE";
Swift:
var touchIDContext = LAContext()
context.localizedFallbackTitle = "YOUR TEXT HERE"
根据 Apple 文档,localizedCancelTitle
适用于 iOS 10
// Fallback button title.
// @discussion Allows fallback button title customization. A default title "Enter Password" is used when
// this property is left nil. If set to empty string, the button will be hidden.
@property (nonatomic, nullable, copy) NSString *localizedFallbackTitle;
// Cancel button title.
// @discussion Allows cancel button title customization. A default title "Cancel" is used when
// this property is left nil or is set to empty string.
@property (nonatomic, nullable, copy) NSString *localizedCancelTitle NS_AVAILABLE(10_12, 10_0);
我已经使用 LAContext
将 TouchID 整合到我的应用程序中,如下所示:
但是,我想将按钮标题的名称从 "Enter Password" 更改为输入 "Enter Security Code"(或类似名称),如下所示:
我该如何更改按钮标题?
这是 LAContext
documentation,这是我的代码:
var touchIDContext = LAContext()
if touchIDContext.canEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, error: &msgError) {
touchIDContext.evaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, localizedReason: touchIDMessage) {
(success: Bool, error: NSError!) -> Void in
if success {
println("Success")
} else {
println("Error: \(error)")
}
}
}
设置 localizedFallbackTitle 属性:
Objective-C:
LAContext *context = [[LAContext alloc] init];
context.localizedFallbackTitle = @"YOUR TEXT HERE";
Swift:
var touchIDContext = LAContext()
context.localizedFallbackTitle = "YOUR TEXT HERE"
根据 Apple 文档,localizedCancelTitle
适用于 iOS 10
// Fallback button title.
// @discussion Allows fallback button title customization. A default title "Enter Password" is used when
// this property is left nil. If set to empty string, the button will be hidden.
@property (nonatomic, nullable, copy) NSString *localizedFallbackTitle;
// Cancel button title.
// @discussion Allows cancel button title customization. A default title "Cancel" is used when
// this property is left nil or is set to empty string.
@property (nonatomic, nullable, copy) NSString *localizedCancelTitle NS_AVAILABLE(10_12, 10_0);