QMUIAlertAction

@interface QMUIAlertAction : NSObject

QMUIAlertController的按钮,初始化完通过QMUIAlertControlleraddAction:方法添加到 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的时候,则使用QMUIAlertControlleralertButtonAttributes或者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 }