行为很接近系统的UIAlertController,使用UIView实现,做了一些样式的自定义。
宽度固定,高度自增长
支持的页面元素
各元素可任意添加与组合
接口
WDActionAlertView.h
1 2
| + (instancetype)alertViewWithTitle:(NSString *)title message:(NSString *)message;
|
1 2
| - (void)addAction:(WDActionAlertViewAction *)action;
|
1 2 3 4 5
|
- (void)addCancelActionWithTitle:(NSString *)title handler:(WDActionAlertViewActionHandler)handler;
|
1 2 3 4 5
|
- (void)addOKActionWithTitle:(NSString *)title handler:(WDActionAlertViewActionHandler)handler;
|
1 2 3
|
- (void)addTextFieldWithConfigurator:(WDActionAlertViewInputViewConfig *(^)())configurator;
|
1 2 3
|
- (void)addTextViewWithConfigurator:(WDActionAlertViewInputViewConfig *(^)())configurator;
|
1 2
| - (NSString *)inputtedText;
|
1 2 3
|
- (NSString *)textWithIdentifier:(NSString *)identifier;
|
1 2
| - (void)showCloseButton;
|
1 2
| - (void)dismissAnimated:(BOOL)animated completion:(void(^)())completion;
|
1 2
| + (BOOL)hasVisibleAlertView;
|
WDActionAlertViewAction
Property
1 2 3 4 5 6 7 8 9 10 11 12
| @property (nonatomic, strong) UIColor *titleColor;
@property (nonatomic, assign) BOOL enabled;
@property (nonatomic, assign) BOOL useBoldFont;
@property (nonatomic, copy, readonly) NSString *actionTitle;
@property (nonatomic, copy, readonly) WDActionAlertViewActionHandler handler;
|
Method
1 2 3 4 5
| + (instancetype)actionWithTitle:(NSString *)title handler:(WDActionAlertViewActionHandler)handler;
- (void)clearHandler;
|
Property
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
|
@property (nonatomic, copy) NSString *identifier;
@property (nonatomic, copy) NSString *placeholder; @property (nonatomic, copy) NSString *text;
@property (nonatomic, assign) NSUInteger maxLength;
@property (nonatomic, copy) NSString *exceedMaxErrorMessage;
@property (nonatomic, assign) UIKeyboardType keyboardType; @property (nonatomic, assign) UIReturnKeyType returnKeyType;
@property (nonatomic, strong) UIFont *font;
@property (nonatomic, assign) BOOL autoFocus;
@property (nonatomic, assign) BOOL secureTextEntry;
|
Method
1 2 3 4 5 6 7 8 9
|
+ (instancetype)defaultTextFieldConfig;
+ (instancetype)defaultTextViewConfig;
|
Demo
一般用法
有一个输入控件时
有多个输入控件时
What’s more
规范里还有一类样式目前没有实现,毕竟目前好像还没有需求,就是这种
需要的话,你们跟我(xujl)说,我再去写