QMUIAlertAction
@interface QMUIAlertAction : NSObject
QMUIAlertController的按钮,初始化完通过QMUIAlertController
的addAction:
方法添加到 AlertController 上即可。
-
初始化
QMUIAlertController
的按钮Declaration
Objective-C
+ (nonnull instancetype) actionWithTitle:(nullable NSString *)title style:(QMUIAlertActionStyle)style handler:(nullable void (^)(__kindof QMUIAlertController *_Nonnull, QMUIAlertAction *_Nonnull))handler;
Swift
convenience init(title: String?, style: QMUIAlertActionStyle, handler: ((QMUIAlertController, QMUIAlertAction) -> Void)? = nil)
Parameters
title
按钮标题
style
按钮style,跟系统一样,有 Default、Cancel、Destructive 三种类型
handler
处理点击事件的block,注意 QMUIAlertAction 点击后必定会隐藏 alertController,不需要手动在 handler 里 hide
Return Value
QMUIAlertController按钮的实例
-
QMUIAlertAction
对应的 button 对象Declaration
Objective-C
@property (nonatomic, strong, readonly) QMUIButton *_Nonnull button;
Swift
var button: QMUIButton { get }
-
QMUIAlertAction
对应的标题Declaration
Objective-C
@property (nonatomic, copy, readonly, nullable) NSString *title;
Swift
var title: String? { get }
-
QMUIAlertAction
对应的样式Declaration
Objective-C
@property (nonatomic, readonly) QMUIAlertActionStyle style;
Swift
var style: QMUIAlertActionStyle { get }
-
QMUIAlertAction
是否允许操作Declaration
Objective-C
@property (nonatomic, getter=isEnabled) BOOL enabled;
Swift
var isEnabled: Bool { get set }
-
QMUIAlertAction
按钮样式,默认nil。当此值为nil的时候,则使用QMUIAlertController
的alertButtonAttributes
或者sheetButtonAttributes
的值。Declaration
Objective-C
@property (nonatomic, strong, nullable) NSDictionary<NSAttributedStringKey, id> *buttonAttributes;
Swift
var buttonAttributes: [NSAttributedString.Key : Any]? { get set }
-
原理同上
buttonAttributes
Declaration
Objective-C
@property (nonatomic, strong, nullable) NSDictionary<NSAttributedStringKey, id> *buttonDisabledAttributes;
Swift
var buttonDisabledAttributes: [NSAttributedString.Key : Any]? { get set }